<van-field
class="textA"
v-model="me"
rows="3"
autosize
type="textarea"
placeholder="请输入内容"
/>
watch: {
a(newVal) {
this.me= [...newVal, ...this.b, ...this.c, ...this.d].join(",")
},
b(newVal) {
this.me = [...this.a, ...newVal, ...this.c, ...this.d].join(",")
},
c(newVal) {
this.me = [...this.a, ...this.b, ...newVal, ...this.d].join(",")
},
d(newVal) {
this.me = [...this.a, ...this.b, ...this.c, ...newVal].join(",")
},
},
用watch监听可以实现,但是代码比较重复
有没有人可以帮我优化一下,我其实想用computed,但是实现不出来
拼接的顺序 也有 讲究吗 。我看 newval位置不一样 。如果不一样的话。计算属性 也不好实现 。
我还是不明白你的需求
computed: {
me () {
const { a, b, c, d } = this
const result = [...a, ...b, ...c, ...d].join(',')
return result
}
}