最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue拖拽排序組件Vue-Slicksort解讀

 更新時間:2023年03月10日 14:35:13   作者:Right atrium  
這篇文章主要介紹了Vue拖拽排序組件Vue-Slicksort,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

一、效果圖

二、安裝組件

npm i vue-slicksort -S

三、使用組件

<div class="maintenance_img mt50 mb50 pl20 pr20" style="font-size: 16px;font-weight: 600;position: relative;">
    <!-- 拖拽 -->
    <SlickList
        :lockToContainerEdges="true"
        lockAxis="x"
        axis="x"
        v-model="maintenanceData.img_list"
        @input="getChangeLists"
        style="display: flex"
        >
        <SlickItem style="z-index: 10000" v-for="(item, index) in maintenanceData.img_list" :index="index" :key="index">
            <div class="maintenance_top">
                <img :src="item" @mouseover="changeMask(index)" @mouseout="changeMask(index)" alt="">
            </div>
        </SlickItem>
    </SlickList>
    <div style="display: flex;position: absolute;bottom: -15px;">
        <div class="maintenance_icon" v-for="(item, index) in maintenanceData.img_list" :key="index">
            <div class="img_bg" :ref="'mask' + index" @mouseover="changeMask(index)" @mouseout="changeMask(index)">
                <Icon @click.stop="isImgShow = true;bigImg = item" class="pointer" size="20" color="#000000" type="md-search" />
                <Icon @click.stop="downloadImg(item)" class="pointer" size="20" color="#000000" type="md-download" />
                <Icon @click.stop="movingItems(4, index)" class="pointer" size="20" color="#000000" type="md-trash" />
            </div>
        </div>
    </div>
    <!-- 600*330 -->
    <div class="add-img" v-if="maintenanceData.img_list.length<5">
        <span>
            <Icon type="md-add" size="30"></Icon>
        </span>
        <p>添加圖片</p>
        <input @change="uploadImegs($event, 1)" type="file" accept="image/*" />
    </div>
</div>
    import { SlickList, SlickItem } from "vue-slicksort";
    export default {
        components:{
            SlickItem,
            SlickList
        },
        data() {
            return {
                maintenanceData: {
                    img_list: [], //圖片
                },
            }
        },
        created() {
            
        },
        methods: {
            getChangeLists(vals) {
                // 拖拽完成后返回新的排序數(shù)組
                console.log(vals);
            },
        },
    }
.maintenance_top {
    display: flex;
    z-index: 10000;
}
.maintenance_top {
    width: 140px;
    height: 78px;
    border: 1px dashed #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    position: relative;
    margin-right: 15px;
}
.maintenance_top > img{
    max-width: 138px;
    max-height: 138px;
    border-radius: 6px;
}
.maintenance_icon{
    width: 140px;
    display: flex;
    align-items: center;
    position: relative;
    margin-right: 15px;
}
.maintenance_img{
    display: flex;
}
.maintenance_img>div>div{
    z-index: 10000;
}
.maintenance_img > .add-img{
    display: block;
    width: 140px;
    height: 78px;
    border-radius: 6px;
} 
.img_bg{
    width: 100%;
    height: 40px;
    position: absolute;
    bottom: -20px;
    left: 0;
    border-radius: 6px;
    display: none;
    align-items: center;
    justify-content: space-evenly;
}

四、組件參數(shù)

名稱類型默認值說明
valueArray-列表的內(nèi)容
axisStringy列表元素可以被橫向拖拽,縱向拖拽還是網(wǎng)格拖拽。用x,y,xy來表示
lockAxisArray-用于排序時在坐標系中鎖定元素的移動
helperClassString-helper的自定義樣式類
transitionDurationNumber300元素移動動畫的持續(xù)時間
pressDelayNumber0如果需要當元素被按下一段時間再允許拖拽,可以設置這個屬性
pressThresholdNumber5移動允許被忽略的閾值,單位是像素
distanceNumber0如果需要在拖拽出一定距離之后才被識別為正在拖拽的元素,可以設置這個屬性
useDragHandleBooleanfalse如果使用HandleDirective,設置為true
useWindowAsScrollContainerBooleanfalse是否設置window為可滾動的容器
hideSortableGhostBooleantrue是否自動隱藏ghost元素
lockToContainerEdgesBooleanfalse是否對正在拖拽的元素鎖定容器邊緣
lockOffsetString50%對正在拖拽的元素鎖定容器邊緣的偏移量
shouldCancelStartFunction-在拖拽開始前這個方法將被調用
getHelperDimensionsFunction-可選方法({node, index, collection}),用于返回SortableHelper的計算尺寸

五、組件方法

名稱參數(shù)說明
sortStartevent, node, index, collection當拖拽開始時觸發(fā)
sortMoveevent當拖拽時鼠標移動時觸發(fā)
sortEndevent, newIndex, oldIndex, collection當拖拽結束時觸發(fā)
inputnewList當拖拽結束后產(chǎn)生新的列表時觸發(fā)

HandleDirective

v-handle 指令在可拖動元素內(nèi)部使用。(即用了這個指令,可以讓拖動只在元素的某個位置生效)

Container 必須由 :useDragHandle 屬性,且設置為 true 時才能正常工作。

這里有關于此的一個簡單元素的例子:

<template>
	<li class="list-item">
	    <!-- 拖動只在 span 元素上生效 -->
	    <span v-handle class="handle"></span>
	    {{item.value}}
	</li>
</template>

<script>
    import { ElementMixin, HandleDirective } from 'vue-slicksort';

    export default {
        mixins: [ElementMixin],
        directives: { handle: HandleDirective },
    };
</script>

總結

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • 詳解vue 配合vue-resource調用接口獲取數(shù)據(jù)

    詳解vue 配合vue-resource調用接口獲取數(shù)據(jù)

    本篇文章主要介紹了vue 配合vue-resource調用接口獲取數(shù)據(jù),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • Vue vee-validate插件的簡單使用

    Vue vee-validate插件的簡單使用

    這個插件可以用來在未使用組件庫,沒有自帶好的校驗規(guī)則時使用,進行表單校驗,非常的實用,感興趣的朋友可以參考下本文,了解該插件的使用方法
    2021-06-06
  • Vue實現(xiàn)Google第三方登錄的示例代碼

    Vue實現(xiàn)Google第三方登錄的示例代碼

    本文記錄作者在vue項目中使用到Google第三方登錄,查詢到的資料文檔也不詳細,故此把自己所遇到的坑及問題詳細的記錄下來。
    2021-07-07
  • vue遞歸組件實現(xiàn)樹形結構

    vue遞歸組件實現(xiàn)樹形結構

    這篇文章主要為大家詳細介紹了vue遞歸組件實現(xiàn)樹形結構,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-09-09
  • vite vue3 路由配置@找不到文件的問題及解決

    vite vue3 路由配置@找不到文件的問題及解決

    在Vite項目中配置路由時,可能會遇到文件路徑錯誤導致的加載失敗問題,常見的解決辦法包括安裝路徑處理插件、正確設置vite.config.js中的路徑別名以及重啟項目,通過正確配置,可以確保路由正確加載對應的界面文件,避免路徑錯誤導致的問題
    2024-10-10
  • 基于vue.js實現(xiàn)側邊菜單欄

    基于vue.js實現(xiàn)側邊菜單欄

    這篇文章主要為大家詳細介紹了基于vue.js實現(xiàn)側邊菜單欄的相關資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • 詳解Vue3 Teleport 的實踐及原理

    詳解Vue3 Teleport 的實踐及原理

    這篇文章主要介紹了Vue3 Teleport 組件的實踐及原理,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-12-12
  • vue如何通過點擊事件實現(xiàn)頁面跳轉詳解

    vue如何通過點擊事件實現(xiàn)頁面跳轉詳解

    頁面跳轉,我們一般都通過路由跳轉實現(xiàn),通常情況下可直接使用router-link標簽實現(xiàn)頁面跳轉,下面這篇文章主要給大家介紹了關于vue如何通過點擊事件實現(xiàn)頁面跳轉的相關資料,需要的朋友可以參考下
    2022-07-07
  • Vue中的errorHandler異常捕獲問題

    Vue中的errorHandler異常捕獲問題

    這篇文章主要介紹了Vue中的errorHandler異常捕獲問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • Vue.js如何利用v-for循環(huán)生成動態(tài)標簽

    Vue.js如何利用v-for循環(huán)生成動態(tài)標簽

    這篇文章主要給大家介紹了關于Vue.js如何利用v-for循環(huán)生成動態(tài)標簽的相關資料,文中通過實例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2022-01-01

最新評論

玉环县| 仪征市| 仙居县| 榕江县| 富平县| 柳江县| 开江县| 驻马店市| 孝昌县| 乐陵市| 鞍山市| 柏乡县| 白银市| 阿克苏市| 迁西县| 大悟县| 任丘市| 华容县| 徐水县| 衡东县| 嘉义市| 建湖县| 汉中市| 绥芬河市| 建水县| 垣曲县| 金寨县| 遵义县| 天峻县| 梨树县| 广东省| 万州区| 阿瓦提县| 沙河市| 涿州市| 兴国县| 昌邑市| 襄城县| 福鼎市| 临颍县| 霞浦县|