页面代码如下,错误提示见附件,请大佬帮忙看看
<template>
<div>
<div>{{drag?'拖拽中':'拖拽停止'}}</div>
<!--使用draggable组件-->
<draggable v-model="myArray" chosenClass="chosen" forceFallback="true" group="people" animation="1000" @end="onEnd">
<transition-group>
<div class="item" v-for="element in myArray" :key="element.id">{{element.name}}</div>
</transition-group>
</draggable>
</div>
</template>
<style scoped>
/被拖拽对象的样式/
.item {
padding: 6px;
background-color: #fdfdfd;
border: solid 1px #eee;
margin-bottom: 10px;
cursor: move;
}
/选中样式/
.chosen {
border: solid 2px #3089dc !important;
}
</style>
<script>
//导入draggable组件
import draggable from 'vuedraggable'
export default {
//注册draggable组件
components: {
draggable,
},
data() {
return {
drag:false,
//定义要被拖拽对象的数组
myArray:[
{people:'cn',id:1,name:'www.itxst.com'},
{people:'cn',id:2,name:'www.baidu.com'},
{people:'cn',id:3,name:'www.taobao.com'},
{people:'us',id:4,name:'www.google.com'}
]
};
},
methods: {
//开始拖拽事件
onStart(){
this.drag=true;
},
//拖拽结束事件
onEnd() {
this.drag=false;
},
},
};
</script>
8***@qq.com
改了,好像没有用
2021-06-02 12:07
dennyjiang
回复 8***@qq.com: 引用对了吗,自定义的话vuedraggable就不要用node_moudles里面的
2021-06-04 19:25
zzdev
牛批啊,改完没有用的话记得重新build一下这个库
2021-08-05 12:29
是东山啊
回复 zzdev: 大佬,啥意思啊,我就是改了没什么用的
2021-12-22 16:47
齐博CMS
感谢大神分享。有用呀
2022-03-07 10:12