欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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如果需要當元素被按下一段時間再允許拖拽,可以設(shè)置這個屬性
pressThresholdNumber5移動允許被忽略的閾值,單位是像素
distanceNumber0如果需要在拖拽出一定距離之后才被識別為正在拖拽的元素,可以設(shè)置這個屬性
useDragHandleBooleanfalse如果使用HandleDirective,設(shè)置為true
useWindowAsScrollContainerBooleanfalse是否設(shè)置window為可滾動的容器
hideSortableGhostBooleantrue是否自動隱藏ghost元素
lockToContainerEdgesBooleanfalse是否對正在拖拽的元素鎖定容器邊緣
lockOffsetString50%對正在拖拽的元素鎖定容器邊緣的偏移量
shouldCancelStartFunction-在拖拽開始前這個方法將被調(diào)用
getHelperDimensionsFunction-可選方法({node, index, collection}),用于返回SortableHelper的計算尺寸

五、組件方法

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

HandleDirective

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

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

這里有關(guān)于此的一個簡單元素的例子:

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

總結(jié)

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

相關(guān)文章

  • vue中如何簡單封裝axios淺析

    vue中如何簡單封裝axios淺析

    Axios 毋庸多說大家在前端開發(fā)中常用的一個發(fā)送 HTTP 請求的庫,用過的都知道,篇文章主要給大家介紹了關(guān)于vue中如何簡單封裝axios的相關(guān)資料,需要的朋友可以參考下
    2021-06-06
  • Vue中從template到j(luò)sx語法教程示例

    Vue中從template到j(luò)sx語法教程示例

    這篇文章主要為大家介紹了Vue中從template到j(luò)sx語法教程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-10-10
  • vue中provide、inject的使用方法案例詳解

    vue中provide、inject的使用方法案例詳解

    本教程是介紹如何在vue中使用provide和inject,在 Vue 中,provide 和 inject 是用于實現(xiàn)祖先組件向后代組件傳遞數(shù)據(jù)的一種方式,對vue中provide、inject的使用方法感興趣的朋友一起看看吧
    2024-02-02
  • vue.js根據(jù)圖片url進行圖片下載

    vue.js根據(jù)圖片url進行圖片下載

    最近在做一個前端vue.js對接的功能模塊時,需要實現(xiàn)一個下載圖片的功能,本文就介紹了vue.js根據(jù)圖片url進行圖片下載,感興趣的可以了解一下
    2021-06-06
  • vue后臺管理之動態(tài)加載路由的方法

    vue后臺管理之動態(tài)加載路由的方法

    這篇文章主要介紹了vue后臺管理之動態(tài)加載路由的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-08-08
  • vue2.0 下拉框默認標題設(shè)置方法

    vue2.0 下拉框默認標題設(shè)置方法

    今天小編就為大家分享一篇vue2.0 下拉框默認標題設(shè)置方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-08-08
  • Vue獲取DOM元素樣式和樣式更改示例

    Vue獲取DOM元素樣式和樣式更改示例

    本篇文章主要介紹了Vue獲取DOM元素樣式和樣式更改示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-03-03
  • Vue導(dǎo)出Excel功能的全過程記錄

    Vue導(dǎo)出Excel功能的全過程記錄

    在開發(fā)后臺管理系統(tǒng)的時候,很多地方都要用到導(dǎo)出excel 表格,比如將table中的數(shù)據(jù)導(dǎo)出到本地,這篇文章主要給大家介紹了關(guān)于Vue導(dǎo)出Excel功能的相關(guān)資料,需要的朋友可以參考下
    2021-07-07
  • vue網(wǎng)絡(luò)請求方案原生網(wǎng)絡(luò)請求和js網(wǎng)絡(luò)請求庫

    vue網(wǎng)絡(luò)請求方案原生網(wǎng)絡(luò)請求和js網(wǎng)絡(luò)請求庫

    這篇文章主要為大家介紹了網(wǎng)絡(luò)請求方案原生網(wǎng)絡(luò)請求和js網(wǎng)絡(luò)請求庫的過程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步
    2021-11-11
  • vue2.0 常用的 UI 庫實例講解

    vue2.0 常用的 UI 庫實例講解

    這篇文章主要介紹了vue2.0 常用的 UI 庫實例講解,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2017-12-12

最新評論