vue Draggable實(shí)現(xiàn)拖動(dòng)改變順序
本文實(shí)例為大家分享了vue Draggable實(shí)現(xiàn)拖動(dòng)改變順序的具體代碼,供大家參考,具體內(nèi)容如下
1、npm install vuedraggable
2、import draggable from 'vuedraggable'
3、示例代碼
Test.vue
<template>
?<ul class="sort-ul">
? ? <div>45454</div>
? ? <draggable ?group="article" :value="sortArr" @input="handleListChange($event)">
? ? ? ?<li v-for="(item,index) in sortArr" :key="index">
? ? ? ? ?<h2>{{item.title}}</h2>
? ? ? ?</li>
? ? </draggable>
? </ul>
</template>
<script>
import Draggable from 'vuedraggable';
export default {
? name: 'Test',
? props:{
? },
? data () {
? ? return {
? ? ? fileList: [],
? ? ? sortArr:[
? ? ? ? {title:"00"},
? ? ? ? {title:"01"},
? ? ? ? {title:"02"},
? ? ? ? {title:"03"},
? ? ? ? {title:"04"},
? ? ? ? {title:"05"},
? ? ? ? {title:"06"},
? ? ? ? {title:"07"},
? ? ? ? {title:"08"},
? ? ? ? {title:"09"},
? ? ? ],
? ? }
? },
? components: {
? ? Draggable, ?
? },
? methods: {
? ? ? // 更新位置
? ? ? handleListChange(event){
? ? ? ? console.log(event);
? ? ? ? this.sortArr = event;
? ? ? }
? },
? mounted () {
? ?
? }
}
</script>
<style>
? ul{
? ? padding: 0;
? ? width: 400px;
? }
? li{
? ? width: 100px;
? ? float:left;
? }
</style>main.js
import Vue from 'vue'
import App from './App'
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
? ? el: '#app',
? ? components: { App },
? ? template: '<App/>'
})app.vue
<template>
? <div id="app">
? ? <Test />
? </div>
</template>
<script>
import Test from '@/components/Test.vue'
export default {
? name: 'App',
? components:{
? ? Test,
? },
? methods: {
? }
}
</script>以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- vue實(shí)現(xiàn)圖片拖動(dòng)排序
- vue實(shí)現(xiàn)移動(dòng)端拖動(dòng)排序
- 基于vue-draggable 實(shí)現(xiàn)三級(jí)拖動(dòng)排序效果
- vue2 拖動(dòng)排序 vuedraggable組件的實(shí)現(xiàn)
- vue實(shí)現(xiàn)拖動(dòng)左側(cè)導(dǎo)航欄變大變小
- vue實(shí)現(xiàn)拖動(dòng)調(diào)整左右兩側(cè)容器大小
- vue+mousemove實(shí)現(xiàn)鼠標(biāo)拖動(dòng)功能(拖動(dòng)過快失效問題解決方法)
- VUE實(shí)現(xiàn)可隨意拖動(dòng)的彈窗組件
- Vue 實(shí)現(xiàn)拖動(dòng)滑塊驗(yàn)證功能(只有css+js沒有后臺(tái)驗(yàn)證步驟)
- Vue中使用elementui與Sortable.js實(shí)現(xiàn)列表拖動(dòng)排序
相關(guān)文章
el-menu實(shí)現(xiàn)橫向溢出截取的示例代碼
在進(jìn)行vue開發(fā)的時(shí)候,我們不可避免會(huì)使用到導(dǎo)航菜單,element方便的為我們提供了導(dǎo)航菜單組件,下面這篇文章主要給大家介紹了關(guān)于el-menu實(shí)現(xiàn)橫向溢出截取的相關(guān)資料,需要的朋友可以參考下2022-06-06
vue實(shí)現(xiàn)行列轉(zhuǎn)換的一種方法
這篇文章主要介紹了vue實(shí)現(xiàn)行列轉(zhuǎn)換的一種方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08
vue-router跳轉(zhuǎn)時(shí)打開新頁面的兩種方法
這篇文章主要給大家介紹了關(guān)于vue-router跳轉(zhuǎn)時(shí)打開新頁面的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue-router具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
Vue入門之?dāng)?shù)量加減運(yùn)算操作示例
這篇文章主要介紹了Vue入門之?dāng)?shù)量加減運(yùn)算操作,結(jié)合實(shí)例形式分析了vue.js基本數(shù)值運(yùn)算相關(guān)操作技巧,需要的朋友可以參考下2018-12-12
Vue2安裝使用MonacoEditor方式(自定義語法,自定義高亮,自定義提示)
這篇文章主要介紹了Vue2安裝使用MonacoEditor方式(自定義語法,自定義高亮,自定義提示),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04
vue resource post請(qǐng)求時(shí)遇到的坑
這篇文章主要介紹了vue resource post請(qǐng)求時(shí)遇到的坑,需要的朋友可以參考下2017-10-10

