色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

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

vue 實(shí)現(xiàn)無(wú)規(guī)則截圖

瀏覽:43日期:2022-09-30 16:38:46

大家所見(jiàn)到的大多數(shù)都是有規(guī)則截圖,可以應(yīng)付大部分的應(yīng)用場(chǎng)景,但是對(duì)于圖片處理,想要將規(guī)則交給用戶,普通的截圖已經(jīng)滿足不了用戶了,那我們能不能前端實(shí)現(xiàn)圖片的任意規(guī)則截取,接下來(lái)讓我一起探討一下吧!

vue 實(shí)現(xiàn)無(wú)規(guī)則截圖

通過(guò) svg 實(shí)現(xiàn) 圖片截取

使用svg中clipPath image標(biāo)簽 通過(guò)id 映射, 動(dòng)態(tài)位置polygon的坐標(biāo),實(shí)現(xiàn)圖片的截取

<div><div @mousemove='mousemove' @mouseup='(e) => {mouseup(e);}'> <!-- 畫(huà)布展示 --> <svg ref='blackSvg' xmlns='http://www.w3.org/2000/svg' > <defs> <clipPath id='clippath'><polygon :points='points'></polygon> </clipPath> </defs> <image xmlns:link='http://www.w3.org/1999/xlink' rel='external nofollow' preserveAspectRatio='none' ></image> </svg> <!-- 拖拽點(diǎn) --> <ul class='interception'> <li v-for='item in 4' :ref='`li${item}`' :key='item' @mousedown='(e) => {mousedown(e, item);}' ></li> </ul> <!-- 底圖展示 --> <img src='https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3228549874,2173006364&fm=26&gp=0.jpg' alt='' /> <!-- 遮罩層 --> <div class='blackDiv'></div> </div> </div>css部分

<style lang='sass'>.blackDiv width: 100% height: 100% position: absolute top: 0 z-index: 2 background: rgba(0,0,0, 1).content width:300px height:300px text-align: left position: relative .blackSvgposition: absolutetop: 0z-index: 3 .blackImgeposition: absolutetop: 0left: 0width: 300pxheight: 300px .interceptionlist-style: noneposition: absolutetop: 0margin: 0padding: 0z-index: 3>li position: absolute width: 10px height: 10px background: blue border-radius: 50% cursor: pointer &:hovertransform: scale(1.2)transition-duration: .2>li:nth-child(1) top: 10px left: 10px>li:nth-child(2) top: 10px left: 100px>li:nth-child(3) top: 100px left: 100px>li:nth-child(4) top: 100px left: 10px</style><script>

export default { name: ’Canvas’, data() { return { points: ’0 0,300 0,300 300,0 300’, // 圖片展示初始化 status: false, index: 0, disX: 0, disY: 0, coordinates: { // 初始化拖拽點(diǎn)1: [0, 0],2: [300, 0],3: [300, 300],4: [0, 300], }, }; }, mounted() { this.$nextTick(() => { for (let key in this.coordinates) {const left = this.coordinates[key][0];const top = this.coordinates[key][1];this.$refs[`li${key}`].style.left = `${left}px`;this.$refs[`li${key}`].style.top = `${top}px`;if (key == 2 || key == 3) { this.$refs[`li${key}`].style.left = `${left - 10}px`;}if (key == 3 || key == 4) { this.$refs[`li${key}`].style.top = `${top - 10}px`;} } document.onmouseup = () => {this.status = false; }; }); }, methods: { //鼠標(biāo)按下 mousedown(e, index) { this.status = true; this.index = index; this.disX = e.clientX - this.$refs[`li${index}`].offsetLeft; this.disY = e.clientY - this.$refs[`li${index}`].offsetTop; }, // 鼠標(biāo)抬起 mouseup(e) { this.status = false; }, // 鼠標(biāo)移動(dòng) mousemove(e) { if (this.status) {let left = e.clientX - this.disX;let top = e.clientY - this.disY;this.$refs[`li${this.index}`].style.left = `${left}px`;this.$refs[`li${this.index}`].style.top = `${top}px`;this.coordinates[this.index] = [left, top];const pointsArr = [];for (let item in this.coordinates) { pointsArr.push( Array.from(this.coordinates[item], (e) => { return e + 5; }) );}this.points = pointsArr.join(’ ’); } }, },};效果圖展示

vue 實(shí)現(xiàn)無(wú)規(guī)則截圖

源碼地址

github地址--> github.com/lgxin/captu…

以上就是vue 實(shí)現(xiàn)無(wú)規(guī)則截圖的詳細(xì)內(nèi)容,更多關(guān)于vue 無(wú)規(guī)則截圖的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 在线观看一区二区三区四区 | 九九亚洲| 97久久精品 | 欧美区一区二区三 | 国产美女一区二区 | 中文字幕国产专区 | 在线观看国产亚洲 | 国产啪精品视频网免费 | 九九国产| 怡红院老首页主页入口 | 另类女最新视频 | 亚洲国产精品免费 | 国产成人在线播放视频 | 亚洲成人综合视频 | 国产91久久久久久久免费 | 亚洲高清成人欧美动作片 | 日韩三级精品 | 久久精品国产亚洲网址 | 午夜欧美 | 三级在线网站 | 欧美高清视频在线 | 毛片一区二区三区 | 台湾精品视频在线播放 | 日本特黄a级高清免费酷网 日本特黄特色 | 国产中文久久精品 | 欧美午夜精品久久久久免费视 | 亚洲成人影院在线观看 | 日本不卡免费高清视频 | 成人欧美精品一区二区不卡 | 纯欧美一级毛片免费 | 国产偷国产偷亚洲高清在线 | 特级毛片在线播放 | 一级做a爰片性色毛片小说 一级做a爰片性色毛片中国 | 午夜久久久久久久 | 国产成人一区二区三区视频免费 | 99久久免费观看 | 日本aaaa级片 | 欧美成年免费a级 | 亚洲国产欧美在线不卡中文 | 午夜不卡av免费 | 国产高清美女一级a毛片久久 |