[英]Vue render function for draggable. How can I add v-model
I cannot find how to add v-model to draggable component in Vue2.我找不到如何将 v-model 添加到 Vue2 中的可拖动组件。 found some example in documentation, but it doesn't work.
在文档中找到了一些示例,但它不起作用。 I tried different variants like adding of list property to component, but it does not work.
我尝试了不同的变体,例如向组件添加列表属性,但它不起作用。
const draggableItem = h('draggable', {
class: '',
attrs: {
'group':'people',
ghostClass: 'ghost',
animation: 200,
handle: '.drag-widget'
},
on: {
input: (event) => {
console.log('on input');
this.data.list = event.target.value
this.$emit('data.list', event.target.value)
},
end: () => {
console.log('drag on end');
this.handleMoveEnd()
},
add: (event) => {
console.log('drag on add', this.data.list);
console.log(event.dataTransfer);
this.handleWidgetAdd(event)
}
}
},
[transitionGroupItem]
);
Could somebody help me with it?有人可以帮我吗?
Tried to add to attributes list property like list: this.data.list, but it also doesn't work试图添加到属性列表属性,如列表:this.data.list,但它也不起作用
V-model is basically combination of reactive prop :value
and input
. V-model 基本上是 reactive prop
:value
和input
的组合。 Value prop for initializing it and input event to update parent's version of it.用于初始化它的值道具和输入事件以更新它的父版本。
Here is very good guide - Adding V-model to custom vue component这是非常好的指南 - Adding V-model to custom vue component
On being added to the list, it should emit('input',data.list)
and also there assign to a data value to avoid mutating the prop.在被添加到列表中时,它应该
emit('input',data.list)
并在那里分配一个数据值以避免改变 prop。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.