日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

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

vue模塊移動(dòng)組件的實(shí)現(xiàn)示例

瀏覽:46日期:2023-01-19 17:03:13

一直都想實(shí)現(xiàn)類似于五百丁中簡(jiǎn)歷填寫中模塊跟隨鼠標(biāo)移動(dòng)的組件,最近閑來無事,自己琢磨實(shí)現(xiàn)了一個(gè)差不多的組件。

vue模塊移動(dòng)組件的實(shí)現(xiàn)示例

其中每個(gè)模塊都是組件調(diào)入(項(xiàng)目經(jīng)驗(yàn)、教育經(jīng)驗(yàn)、工作經(jīng)驗(yàn)等),所以這里也用到了動(dòng)態(tài)加載組件方式。

思路:鼠標(biāo)移入模塊,顯示相應(yīng)模塊的點(diǎn)擊移動(dòng)按鈕,點(diǎn)擊A模塊移動(dòng)按鈕,此時(shí)原先A模塊所在的位置上變?yōu)橥蟿?dòng)到這里綠框模塊,同時(shí)鼠標(biāo)下懸浮著A模塊,鼠標(biāo)移動(dòng),懸浮的A模塊跟隨移動(dòng),綠框也跟隨上下移動(dòng)。

父組件

1、父組件template中的代碼

<div ref='compBox'> <component v-for='(item, index) in comRoute' :is='item' :key='index' @getData='getData'></component> <div : ref='translateBox' v-if='transType'> <component :is='transCom'></component> </div></div>

2、data中定義的屬性

comList: [’educationExp’, ’workExp’, ’projectExp’], // 模塊列表comLen: 0, // 模塊的長(zhǎng)度comType: ’’, // 當(dāng)前移動(dòng)的模塊transType: ’’, // 當(dāng)前移動(dòng)的模塊coordinate: { // 鼠標(biāo)坐標(biāo) mouseX: 0, mouseY: 0,},downFlag: false, // 當(dāng)前是否點(diǎn)擊模塊移動(dòng)mouseYBefore: 0, // 記錄鼠標(biāo)點(diǎn)擊時(shí)Y坐標(biāo)以及鼠標(biāo)每移動(dòng)30后重新記錄鼠標(biāo)Y坐標(biāo)mouseYLast: 0, // 實(shí)時(shí)記錄鼠標(biāo)移動(dòng)時(shí)的Y坐標(biāo)nowCom: ’’, // 移動(dòng)模塊時(shí),上一個(gè)模塊或者下一個(gè)模塊的名稱forFlage: false, // forEach遍歷結(jié)束的標(biāo)識(shí)comRoute: [], // 動(dòng)態(tài)加載組件列表transCom: null, // 點(diǎn)擊后懸浮的組件compBox: null, // 獲取當(dāng)前組件在頁面中的位置信息

3、scrollTop為頁面滾動(dòng)的距頂部的距離,從父組件傳過來

props: { scrollTop: Number,}

4、watch一些屬性

watch: { comList: { handler(val) { this.getCom(val); // 模塊列表改變時(shí),實(shí)時(shí)加載組件 }, deep: true, immediate: true, // 聲明了之后會(huì)立馬執(zhí)行handler里面的函數(shù) }, transType(val) { // 懸浮模塊加載組件 if (val) { this.transCom = () => import(`./default/${val}`); } }, scrollTop: { // 監(jiān)聽頁面滾動(dòng) handler() {}, immediate: true, }, comType(newVal) { if (newVal) { this.comList.forEach((item, index) => { if (item === newVal) { this.comList[index] = ’moveBox’; // 將組建列表中為comType的元素改為moveBox組件 } }); this.getCom(this.comList); } }, downFlag(newVal) { // 鼠標(biāo)已經(jīng)點(diǎn)擊 const nowThis = this; document.onmousemove = function (e) { if (newVal) { // 鼠標(biāo)移動(dòng)賦值 nowThis.coordinate.mouseX = e.clientX; nowThis.coordinate.mouseY = e.clientY; } }; document.onmouseup = function () { // 鼠標(biāo)松開 document.onmousemove = null; if (newVal) { nowThis.transType = ’’; // 懸浮組件置空 nowThis.comList.forEach((item, index) => { if (item === ’moveBox’) { // 尋找moveBox所在位置 nowThis.comList[index] = nowThis.comType; // 還原成點(diǎn)擊組件 } }); nowThis.downFlag = false; nowThis.comType = ’’; nowThis.getCom(nowThis.comList); } }; }, coordinate: { handler(newVal) { // 懸浮組件位置 this.$refs.translateBox.style.top = `${newVal.mouseY + this.scrollTop - 40 - this.compBox.y}px`; this.$refs.translateBox.style.left = `${newVal.mouseX - this.compBox.x - 200}px`; this.mouseYLast = newVal.mouseY; }, deep: true, }, mouseYLast(newVal) { // 鼠標(biāo)移動(dòng)Y坐標(biāo) this.forFlage = false; if (newVal - this.mouseYBefore > 30) { // 移動(dòng)30鼠標(biāo)向下移,每移動(dòng)30,moveBox移動(dòng)一次 this.comList.forEach((item, index) => { if (item === ’moveBox’ && index < this.comLen - 1 && !this.forFlage) { this.nowCom = this.comList[index + 1]; this.$set(this.comList, index + 1, ’moveBox’); this.$set(this.comList, index, this.nowCom); this.mouseYBefore = newVal; this.forFlage = true; } }); } else if (newVal - this.mouseYBefore < -30) { // 鼠標(biāo)向上移 this.comList.forEach((item, index) => { if (item === ’moveBox’ && index > 0 && !this.forFlage) { this.nowCom = this.comList[index - 1]; // this.comList[index - 1] = ’moveBox’; // this.comList[index] = this.nowCom; // this.comList[index]數(shù)組中采用這種方式賦值,vue是不能檢測(cè)到數(shù)組的變動(dòng)的 this.$set(this.comList, index - 1, ’moveBox’); this.$set(this.comList, index, this.nowCom); this.mouseYBefore = newVal; this.forFlage = true; } }); } },},

其中 forFlage的作用是,在forEach中不能使用break這樣來結(jié)束循環(huán),所以用forFlage來表示,當(dāng)遍歷到moveBox后, 就結(jié)束遍歷

5、methods

methods: { getCom(val) { this.comRoute = []; val.forEach((item) => { this.comRoute.push(() => import(`./default/${item}`)); }); }, getData(data, dataY, dataX) { // 模塊組件點(diǎn)擊后,父組件中調(diào)用此方法,并傳值過來 this.comType = data; this.transType = data; // 目前考慮點(diǎn)擊后立即移動(dòng),點(diǎn)擊不移動(dòng)的情況后期再考慮 this.downFlag = true; this.mouseYBefore = dataY; this.$nextTick(() => { this.$refs.translateBox.style.top = `${dataY + this.scrollTop - 40 - this.compBox.y}px`; this.$refs.translateBox.style.left = `${dataX - this.compBox.x - 200}px`; }); },},

6、mounted

mounted() { this.comLen = this.comList.length; this.compBox = this.$refs.compBox.getBoundingClientRect(); const that = this; window.onresize = () => (() => { that.compBox = this.$refs.compBox.getBoundingClientRect(); })();},

子組件

1、子組件template代碼

<div class='pad-box hover-box name-box'> <p class='absolute-box'> <i @mousedown='mouseDown'></i> <i class='el-icon-circle-plus operation-icon'></i> <i class='el-icon-s-tools operation-icon'></i> </p> 教育經(jīng)驗(yàn)</div>

2、script

export default { name: ’educationExp’, data() { return { comType: ’educationExp’, mouseYBefore: 0, mouseXBefore: 0, }; }, methods: { mouseDown(e) { this.mouseYBefore = e.clientY; this.mouseXBefore = e.clientX; this.$emit(’getData’, this.comType, this.mouseYBefore, this.mouseXBefore); }, },};

到此這篇關(guān)于vue模塊移動(dòng)組件的實(shí)現(xiàn)示例的文章就介紹到這了,更多相關(guān)vue模塊移動(dòng)組件內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Vue
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
久久xxx视频| 中国女人久久久| 亚洲精品第一| 蜜桃av一区二区| 免费日本视频一区| 蜜桃视频在线观看一区二区| 亚洲欧美日韩国产综合精品二区 | 99久久九九| 丝袜美腿诱惑一区二区三区| 久久久久一区| 欧美网站在线| 少妇精品在线| 国产精品久久久久9999高清| 热久久免费视频| 亚洲欧美网站在线观看| 91成人在线精品视频| 国产精品视频一区二区三区| 麻豆久久久久久久| 免费观看亚洲| 伊人成人网在线看| 视频一区在线播放| 在线精品视频一区| 国产精品亚洲综合久久| 国产成人免费精品| 电影亚洲精品噜噜在线观看| 欧美另类综合| 午夜亚洲福利| 久久精品网址| 九九综合九九| 日韩高清在线不卡| 精品一区av| 欧美福利专区| 日韩av一二三| 国产欧美一区二区三区精品酒店| 亚洲午夜黄色| 婷婷精品久久久久久久久久不卡| 国产精品亚洲欧美| 日韩欧美视频专区| 久久xxxx精品视频| 免费一区二区三区在线视频| 久久精品成人| 日本中文字幕视频一区| 激情久久99| 亚洲综合不卡| 精品理论电影在线| 国产精品人人爽人人做我的可爱 | 丝袜脚交一区二区| 欧美国产另类| 欧美日韩国产探花| 国产精品sm| 999国产精品视频| 日本不卡一区二区| 亚洲成人av观看| 日本少妇精品亚洲第一区| 四虎成人av| 日韩专区一卡二卡| 中文字幕在线高清| 日本不卡高清视频| 色老板在线视频一区二区| 日韩av三区| 免费国产自久久久久三四区久久 | 国产精品一页| 亚洲男女av一区二区| 国产精品网在线观看| 久久亚洲精品中文字幕蜜潮电影| 蜜桃av一区二区| 国产一区2区在线观看| 久久xxxx精品视频| 国产91在线播放精品| 日韩制服丝袜av| 国产不卡人人| 日韩av三区| 欧美激情另类| 日本在线观看不卡视频| 激情欧美一区二区三区| 欧美精品成人| 婷婷综合一区| 免费黄色成人| 国产日韩欧美三区| 国产精品婷婷| 欧美不卡高清一区二区三区| 国产精品分类| 日韩精品亚洲aⅴ在线影院| 1000部精品久久久久久久久| 欧美激情精品| 亚久久调教视频| 欧美精品九九| 免费看av不卡| 国产伊人久久| 国产精品一区二区av日韩在线| 性色av一区二区怡红| 久久夜夜操妹子| 国产一区丝袜| 国产伦精品一区二区三区千人斩| 9色国产精品| 久久九九99| 欧美激情另类| 国产一区一一区高清不卡| 日本午夜精品久久久久| 模特精品在线| 亚洲一区日韩| 欧美日韩国产在线一区| 久久中文视频| 久久久一本精品| 日韩高清中文字幕一区二区| av免费不卡国产观看| 精品色999| 美女精品视频在线| 国产精品啊v在线| 国产三级一区| 国产日韩一区二区三区在线| 日本成人在线网站| 日韩精品免费一区二区夜夜嗨 | 欧美+日本+国产+在线a∨观看| 伊人久久国产| 国产 日韩 欧美 综合 一区| 精品在线网站观看| 精品国产不卡| 精品在线网站观看| 精品午夜视频| 91亚洲国产成人久久精品| 国产欧美一区二区三区精品酒店| аⅴ资源天堂资源库在线| 亚洲涩涩在线| 久久精品国产99久久| 激情欧美一区| 日韩影院免费视频| 日韩精品社区| 欧美精品导航| 精品国产午夜| 日韩精品久久久久久久电影99爱| av在线日韩| 伊人精品视频| 免费一级片91| 国产日本精品| 国产999精品在线观看| 久久精品不卡| 久久精品青草| 亚洲欧美成人综合| 免费日韩精品中文字幕视频在线| 亚洲欧洲一区| 男女激情视频一区| 欧美日韩xxxx| 精品国产欧美| 成人看片网站| 国产精品美女| 日韩一区二区三区精品| 国产午夜一区| 欧美激情 亚洲a∨综合| 成人亚洲欧美| 夜夜嗨一区二区| 亚洲69av| 精品中文在线| 香蕉精品视频在线观看| 中文字幕一区二区三区日韩精品| 日韩av中文字幕一区二区三区| 国内一区二区三区| 蜜臀91精品国产高清在线观看| 日韩在线播放一区二区| 国产精品天堂蜜av在线播放| 狠狠躁少妇一区二区三区| 在线精品小视频| 奇米色欧美一区二区三区| 九九久久国产| 亚洲男女自偷自拍| 牛牛精品成人免费视频| 久久精品二区三区| 欧美一区=区三区| 亚洲欧洲美洲av| 亚洲视频电影在线| 粉嫩av一区二区三区四区五区| 五月天久久久| 欧美国产专区| 国产精品成人a在线观看| 久久永久免费| 久久国产亚洲| 日韩精品亚洲aⅴ在线影院| 麻豆久久一区二区| 秋霞国产精品| 日韩高清不卡一区| 日韩av在线中文字幕| 国产一区成人| 精品视频在线你懂得| 在线亚洲免费| 狂野欧美性猛交xxxx| 尤物在线精品| 麻豆成人综合网| 亚洲在线观看| 国产一区二区三区久久| 亚洲欧美日本视频在线观看| 国产成人精品福利| 日本亚洲视频在线| 视频福利一区| 国产欧美亚洲精品a| 精品一区在线| 国产一区二区三区四区五区| 综合亚洲视频| 日韩精品一区二区三区免费观影 | 亚洲黄色中文字幕| 亚洲bt欧美bt精品777|