vue 循环中怎么监听 v-model='xx'

div.form-group(v-for="item in items")
input.form-control.w60.mgr2(type='text' placeholder='输入商品id' v-model="item.fur_id_poi_furnitures")

this.$watch('item.fur_id_poi_furnitures',function () {})

阅读 3.4k
2 个回答

监听外层 items,然后根据 val,oldVal,判断变化的元素是哪个,再做相应处理

watch: {
  items: {
    handler: function (val, oldVal) {
      console.log('a thing changed')
    },
    deep: true
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题