• vue列表拖拽组件 vue-dragging


    安装

    $ npm install awe-dnd --save
    

    应用 

    在main.js中,通过Vue.use导入插件
    import VueDND from 'awe-dnd'
    
    Vue.use(VueDND)

    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> 

    vue2.0的使用

    <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>

    vue1.0的使用

    <div class="color-list">
        <div 
            class="color-item" 
            v-for="color in colors" v-dragging="{ item: color, list: colors, group: 'color', key: color.text }"
            track-by="text"
        >{{color.text}}</div>
    </div>
    
    添加事件
    <div class="color-list">
        <div 
            class="color-item" 
            v-for="color in colors" v-dragging="{ item: color, list: colors, group: 'color', otherData: otherData }"
            :key="color.text"
        >{{color.text}}</div>
    </div>
    
    export default {
      mounted () {
        this.$dragging.$on('dragged', ({ value }) => {
          console.log(value.item)
          console.log(value.list)
          console.log(value.otherData)
        })
        this.$dragging.$on('dragend', () => {
            
        })
      }
    }
    

      

  • 相关阅读:
    Spring读书笔记
    window.open参数详解
    在spring security3上实现验证码
    Struts2.1 标签详细说明
    总结一下log4j
    【转】hibernate映射oracle自增长
    Java中四舍五入保留七位小数
    求三个整数的最小公倍数
    boxshadow 曲线阴影和翘边阴影
    <div> <p> <span>的用法和区别
  • 原文地址:https://www.cnblogs.com/woshidouzia/p/9304813.html
Copyright © 2020-2023  润新知