Gij*_*ese 2 vue.js vue-component vuejs2
我正在使用以下代码来显示传递值“类别”的组件。类别根据用户交互而变化。但是,一旦加载了一个组件,它的数据不会根据 props 的变化而改变。
<button @click="selected='new'">Change</button>
<popup :category="selected"></popup>
data() {
return {
selected: 'test'
}
}
Run Code Online (Sandbox Code Playgroud)
你将不得不把观察者上category
的 popup
器件,如下列:
watch: {
category: function(newVal){
this.selected = newVal // or this.openPopup(newVal) is this suits
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10039 次 |
最近记录: |