mapState如果和普通的局部计算属性混合使用,使用对象展开运算符(…)
data () {
return {
order: {
orderId: '',
amount: 0.0
}
}
},
computed: {
amount () {
return this.order.amount
},
...mapState({
order_create_watcher: state => state.order.order_create
order_confirm_watcher: state => state.order.order_confirm
})
},
watch: {
amount: 'amountWatcher',
order_create_watcher: {
handler: 'orderCreateWatcher',
deep: true
},
order_confirm_watcher: {
handler: 'orderConfirmWatcher',
deep: true
}
},
methods: {
amountWatcher (val, oldVal) {
...
},
orderCreateWatcher (val, oldVal) {
...
},
orderConfirmWatcher (val, oldVal) {
...
}
}