Vue---拖拽

好用的拖拽组件:Awe-dnd

npm install awe-dnd --save

集成:main.js

import VueDND from 'awe-dnd'
 
Vue.use(VueDND)

使用:

<!--your.vue-->
<script>
export default {
  data () {
    return {
        colors: [{
            text: "Aquamarine"
        }, {
            text: "Hotpink"
        }, {
            text: "Gold"
        }, {
            text: "Crimson"
        }, {
            text: "Blueviolet"
        }, {
            text: "Lightblue"
        }, {
            text: "Cornflowerblue"
        }, {
            text: "Skyblue"
        }, {
            text: "Burlywood"
        }]
    }
  }
}
</script>
 
<template>
  <div class="color-list">
      <div
          class="color-item"
          v-for="color in colors" v-dragging="{ item: color, list: colors, group: 'color' }"
          :key="color.text"
      >{{color.text}}</div>
  </div>
</template>

参考:

https://blog.csdn.net/gitblog_00027/article/details/141041469

打完收工!

posted @ 2025-07-15 16:08  帅到要去报警  阅读(19)  评论(0)    收藏  举报