I have to show the name prop as initials. It shows the initials fine on mount. but when I later change the value in the parent component. It doesn't change values. I tried computed as well but it shows that I didn't use the computed property. What am I missing here?
got this two errors
'computedInitial:' is defined but never used no-unused-labels
'get' is not defined
code
<template>
<div>
{{ showInitial }}
</div>
</template>
<script>
export default {
props: {
name: {
type: String,
},
data() {
return {
showInitial: null,
};
},
computed(){
computedInitial:{
get()
return this.name
}
},
mounted() {
let initials = this.computedInitial.match(/\b\w/g) || [];
this.showInitial = ((initials.shift() || "") + (initials.pop() || "")).toUpperCase();
},
};