为什么在cube的设计的时候inputValue写在了data而不是计算属性里面

来源:1-1 导学

李行知

2018-08-07

在cube的设计中有

inputValue: this.data() {
return {
inputValue: this.value,,


value(newValue) {
this.inputValue = newValue
},
inputValue(newValue) {
this.$emit(EVENT_INPUT, newValue)
},

这样的设计

包括element跟vux也是这种类型的设计

这种类型的设计比起

computed: {
currentValue: {
get () {
return this.value ? this.value : ''
},
set (v) {
this.$emit('input', v)
},
},
},

这种放入到computed的设计有什么好处呢?

写回答

1回答

ustbhuangyi

2018-08-08

通常我们很少设置计算属性的 setter 吧

0
2
李行知
非常感谢!
2018-08-08
共2条回复

Vue2.0高级应用教学实战,开发企业级移动端音乐Web App

Vue.js高级知识应用大集合,实战企业级APP,教你搞定组件化开发。

5432 学习 · 3805 问题

查看课程