我的vue应用程序具有以下设置
var store = {
...
state: {
currentCustomer:{},
},
};
当前客户具有一个称为付款方式的对象的属性
app:
var app= new Vue({
el:'#application',
data: {
sharedState: store.state
}
});
和几个组件:
Vue.component('user_search', {
template: '#user_search-template',
data() {
return {
sharedState: store.state
}
},
methods: {
getCustomerData: function () {
this.sharedState.currentCustomer(c);
}
mounted: function () {
...
}
});
和
Vue.component('paymentdetails',{
template: '#payment_details_template',
data(){
return{
sharedState: store.state
}
},
mounted:function(){
...
}});
问题是这样的。付款方式组件未绑定到嵌套在当前客户对象内的付款明细对象
有什么建议吗?
答案 0 :(得分:1)
是的,我认为您正在寻找的是用于访问数据的计算属性。
Vue.component('paymentdetails',{
template: '#payment_details_template',
computed{
sharedState() {
return store.state
}
},
mounted:function(){
...
}});
也许尝试一下,看看它是如何工作的。