国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術(shù)文章
文章詳情頁

Vue實(shí)現(xiàn)div滾輪放大縮小

瀏覽:21日期:2022-09-28 18:35:44

Vue項(xiàng)目中實(shí)現(xiàn)div滾輪放大縮小,拖拽效果,類似畫布效果

Vue實(shí)現(xiàn)div滾輪放大縮小

1、引入插件vue-draggable-resizable,點(diǎn)我進(jìn)入GitHub地址。

1)、npm install --save vue-draggable-resizable2)、main.js文件中

import VueDraggableResizable from ’vue-draggable-resizable’import ’vue-draggable-resizable/dist/VueDraggableResizable.css’Vue.component(’vue-draggable-resizable’, VueDraggableResizable)

3)、vue文件中使用

main.js:

import Vue from ’vue’import App from ’./App’import router from ’./router’Vue.config.productionTip = false// iviewimport ViewUI from ’view-design’;import ’view-design/dist/styles/iview.css’;Vue.use(ViewUI)// 拖拽·縮放·畫布插件import VueDraggableResizable from ’vue-draggable-resizable’import ’vue-draggable-resizable/dist/VueDraggableResizable.css’Vue.component(’vue-draggable-resizable’, VueDraggableResizable)new Vue({ el: ’#app’, router, components: { App }, template: ’<App/>’})

vue文件: 只需要關(guān)注引入組件vue-draggable-resizable配置項(xiàng)和handleTableWheel、tableZoom方法即可。

<template> <div class='is'><div > <!-- 引入組件. :lock-aspect-ratio='true':鎖定縱橫比例 :resizable='false': 不可縮放--> <vue-draggable-resizablew='auto'h='auto':grid='[20,40]':x='10':y='10':resizable='false' ><div ref='table' @wheel.prevent='handleTableWheel($event)'> <-- iview表格,無關(guān)緊要,任何div即可 --> <Table:columns='columns1':data='data1'size='small':disabled-hover='true'border ><template slot-scope='{ row, index }' slot='name'> <Tooltip :content='row.name' placement='top' transfer><span @click='handleCellClick(row)'>{{ row.name }}</span> </Tooltip></template> </Table></div> </vue-draggable-resizable></div> </div></template><script>import VueDraggableResizable from 'vue-draggable-resizable';export default { name: 'is', data() {return { columns1: [{ title: 'Name', slot: 'name', width: 120},{ title: 'Age', key: 'age', width: 120},{ title: 'Address', key: 'address', width: 120},{ title: 'Name', key: 'name', width: 120},{ title: 'Age', key: 'age', width: 120},{ title: 'Address', key: 'address', width: 120},{ title: 'Name', key: 'name', width: 120},{ title: 'Age', key: 'age', width: 120},{ title: 'Address', key: 'address', width: 120} ], data1: [{ name: 'John Brown', age: 18, address: 'New York No. 1 Lake Park'},{ name: 'Jim Green', age: 25, address: 'London No. 1 Lake Park', cellClassName: {age: 'demo-table-info-cell-age',address: 'demo-table-info-cell-address' }},{ name: 'Joe Black', age: 30, address: 'Sydney No. 1 Lake Park'},{ name: 'Jon Snow', age: 26, address: 'Ottawa No. 2 Lake Park', cellClassName: {name: 'demo-table-info-cell-name' }},{ name: 'John Brown', age: 18, address: 'New York No. 1 Lake Park'},{ name: 'Jim Green', age: 25, address: 'London No. 1 Lake Park', cellClassName: {age: 'demo-table-info-cell-age',address: 'demo-table-info-cell-address' }},{ name: 'Joe Black', age: 30, address: 'Sydney No. 1 Lake Park'},{ name: 'Jon Snow', age: 26, address: 'Ottawa No. 2 Lake Park', cellClassName: {name: 'demo-table-info-cell-name' }} ]}; }, mounted() {}, methods: {handleTableWheel(event) { let obj = this.$refs.table; return this.tableZoom(obj, event);},tableZoom(obj, event) { // 一開始默認(rèn)是100% let zoom = parseInt(obj.style.zoom, 10) || 100; // 滾輪滾一下wheelDelta的值增加或減少120 zoom += event.wheelDelta / 12; if (zoom > 0) {obj.style.zoom = zoom + '%'; } return false;},// 單擊單元格事件(用于測試拖拽是否阻止了表格默認(rèn)事件,無關(guān)緊要)handleCellClick(row) { this.$Message.info('你點(diǎn)擊了' + row.name);} }};</script><style scoped lang='less'>.is { .table {.name { cursor: pointer;} }}// iview表格樣式:iview官網(wǎng)復(fù)制就行,無關(guān)緊要/deep/ .ivu-table { .demo-table-info-row td {background-color: #2db7f5;color: #fff; } td.demo-table-info-column {background-color: #2db7f5;color: #fff; } .demo-table-error-row td {background-color: #ff6600;color: #fff; } .demo-table-info-cell-name {background-color: #2db7f5;color: #fff; } .demo-table-info-cell-age {background-color: #ff6600;color: #fff; } .demo-table-info-cell-address {background-color: #187;color: #fff; }}// 去除畫布中div邊框.vdr { border: none;}</style>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 天堂8中文在线最新版在线 天堂8资源8在线 | 综合558欧美成人永久网站 | 在线视频免费国产成人 | 成人中文字幕在线观看 | 国产欧美一区二区三区在线 | 久久99精品久久久久久野外 | 亚洲国产欧美日韩精品一区二区三区 | a级做爰视频免费观看 | 国产精品久久国产三级国电话系列 | 国产成人精品高清在线 | a毛片全部免费播放 | 国产日本欧美高清免费区 | 看成年女人免费午夜视频 | 亚洲一区免费在线观看 | 国产成人精品一区二区三在线观看 | 一区二区影视 | 国产精品久久影院 | 亚洲一区欧美二区 | 日本暖暖视频在线播放 | 免费一级欧美片在线观免看 | 99精品欧美一区二区三区美图 | 国产成人一区免费观看 | 亚洲国产精品乱码在线观看97 | 日b毛片 | 日本一级毛片免费 | 国产性夜夜春夜夜爽30 | 三级黄色在线 | 亚洲色欧美 | 欧美成人艳星在线播放 | 99热热久久这里只有精品166 | 免费的一级片网站 | gay毛片| 欧美精品久久久亚洲 | 一级毛片无毒不卡直接观看 | 91精品国产综合久久欧美 | 三级黄色在线播放 | 在线视频亚洲 | 国产精品久久久久久久久免费 | 日本免费人成在线网站 | 黄在线观看在线播放720p | 亚洲人成网址在线观看 |