vue 监听对象里某个值的变化
时间:2020-06-08 11:29:05
收藏:0
阅读:685
假设vue里有个form表单对象:
form: { id: null, projectName: null, state: ‘100‘, typeId: null, typeName: null }
当typeId变化时,实时修改typeName的值(因为是回调修改,其实有点延时)
使用watch监听typeId
watch: { ‘form.typeId‘: { handler: function() { if (!this.form.typeId) { this.form.typeName = null return } this.form.typeName = this.projectTypeOptions.find(item => { return item.key === this.form.typeId }).display_name } } }
原文:https://www.cnblogs.com/asker009/p/13064013.html
评论(0)