這篇文章將為大家詳細(xì)講解有關(guān)vue中draggable resizable如何實(shí)現(xiàn)可拖拽縮放的組件功能,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
北林ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
雖然之前適配過舊版組件,但是因?yàn)?.0版本原作者對代碼進(jìn)行了重構(gòu),原來修改的代碼照搬是不可能的了。
所以也就一直沒有將 沖突檢測 以及 吸附對齊 功能適配到2.0版本,最近正好有時(shí)間就適配一下。
新增特征
功能預(yù)覽
項(xiàng)目地址
github.com/gorkys/vue-…
如果喜歡該項(xiàng)目,歡迎 Star
新增Props
isConflictCheck
Type: Boolean
Required: false
Default: false
定義組件是否開啟沖突檢測。
<vue-draggable-resizable :is-conflict-check="true">
snap
Type: Boolean
Required: false
Default: false
定義組件是否開啟元素對齊。
<vue-draggable-resizable :snap="true">
snapTolerance
Type: Number
Required: false
Default: 5
當(dāng)調(diào)用 snap 時(shí),定義組件與元素之間的對齊距離,以像素(px)為單位。
<vue-draggable-resizable :snap="true" :snap-tolerance="20">
其它屬性請參考 vue-draggable-resizable 官方文檔
安裝使用
$ npm install --save vue-draggable-resizable-gorkys
全局注冊組件
//main.js
import Vue from 'vue'
import vdr from 'vue-draggable-resizable-gorkys'
// 導(dǎo)入默認(rèn)樣式
import 'vue-draggable-resizable-gorkys/dist/VueDraggableResizable.css'
Vue.component('vdr', vdr)
局部注冊組件
<template>
<div >
<vdr :w="100" :h="100" v-on:dragging="onDrag" v-on:resizing="onResize" :parent="true">
<p>Hello! I'm a flexible component. You can drag me around and you can resize me.<br>
X: {{ x }} / Y: {{ y }} - Width: {{ width }} / Height: {{ height }}</p>
</vdr>
<vdr
:w="200"
:h="200"
:parent="true"
:debug="false"
:min-width="200"
:min-height="200"
:isConflictCheck="true"
:snap="true"
:snapTolerance="20"
>
</vdr>
</div>
</template>
<script>
import vdr from 'vue-draggable-resizable-gorkys'
import 'vue-draggable-resizable-gorkys/dist/VueDraggableResizable.css'
export default {
components: {vdr},
data: function () {
return {
width: 0,
height: 0,
x: 0,
y: 0
}
},
methods: {
onResize: function (x, y, width, height) {
this.x = x
this.y = y
this.width = width
this.height = height
},
onDrag: function (x, y) {
this.x = x
this.y = y
}
}
}
</script>
為什么要使用Vue
Vue是一款友好的、多用途且高性能的JavaScript框架,使用vue可以創(chuàng)建可維護(hù)性和可測試性更強(qiáng)的代碼庫,Vue允許可以將一個(gè)網(wǎng)頁分割成可復(fù)用的組件,每個(gè)組件都包含屬于自己的HTML、CSS、JavaScript,以用來渲染網(wǎng)頁中相應(yīng)的地方,所以越來越多的前端開發(fā)者使用vue。
關(guān)于“vue中draggable resizable如何實(shí)現(xiàn)可拖拽縮放的組件功能”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。
分享文章:vue中draggableresizable如何實(shí)現(xiàn)可拖拽縮放的組件功能
文章起源:http://muchs.cn/article2/johhoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、網(wǎng)站排名、小程序開發(fā)、營銷型網(wǎng)站建設(shè)
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源:
創(chuàng)新互聯(lián)