go straight to the code:
</my-child>
</div>
// js
Vue.component("my-child", {
props: [
"test"
],
data() {
return {
myTest: this.test
}
},
template: "<div>{{ myTest }}</div>"
})
new Vue({
el: "-sharpapp",
data: {
test: "test"
},
methods: {
"clickChange" () {
this.test = "haha"
console.log(this.test)
}
}
})
when the test passed by the parent component changes, but the myTest assigned to the child component does not change, is there any way to get it quickly? Except for the watch method