How to modify the default logic of the createGetter function in Vue3? If the property value in props or data is a variable with double curly braces “{{}}”, it is considered a variable that needs further processing. You need to add custom logic to turn these variables into specific replacement values.
Note that there are many Vue files in the project, so it is too cumbersome to modify them one by one. Therefore, I want to directly modify the createGetter function of Vue3, which will require the least amount of code modification.
Here’s an example of what you’re trying to do:
<template>
<div>
<div>{{widgetName}}</div>
<div>{{productName}}</div>
</div>
</template>
<script>
export default {
components: {},
props: {
widgetName: {
type: String,
default: '{{table.name}}',
}
},
data () {
return {
productName: '{{product.name}}',
product: {
name: 'phone'
},
table: {
name: 'good'
},
};
},
created () {
console.log(this.widgetName) // show 'good'
console.log(this.productName) // show 'phone'
},
};
</script>