Vue實(shí)現(xiàn)底部側(cè)邊工具欄的實(shí)例代碼
下載地址: https://github.com/imxiaoer/FloatToolBar
因?yàn)槭莻€(gè)常見(jiàn)的功能,所以寫(xiě)個(gè)組件。效果圖如下:
組件具體代碼如下: tool.vue
<template> <ul class="float-tool"> <li class="hasChild"> <span class="tool-icon icon0"></span> <span>聯(lián)系電話</span> <div class="txtbox"> <span>請(qǐng)撥 102-0012-9242</span> </div> </li> <li> <span class="tool-icon icon1"></span> <span>QQ 客服</span> </li> <li class="hasChild"> <span class="tool-icon icon2"></span> <span>APP下載</span> <div class="picbox"> <img src="./wechat.jpg" alt="微信二維碼"> </div> </li> <li class="hasChild"> <span class="tool-icon icon3"></span> <span>關(guān)注微信</span> <div class="picbox"> <img src="./wechat.jpg" alt="微信二維碼"> </div> </li> <li onclick="window.scrollTo(0, 0)"> <span class="tool-icon icon4"></span> <span>返回頂部</span> </li> </ul> </template> <script type="text/ecmascript-6"> export default { } </script> <style lang="stylus" rel="stylesheet/stylus"> .float-tool position: fixed right: 10px bottom: 10px z-index: 99 width: 55px font-size: 12px li position: relative margin-bottom: 5px width: 55px height: 55px text-align: center color: #FFF background-color: #6b4ec2 cursor: pointer &.hasChild:hover > div display: block .tool-icon display: block width: 55px height: 35px background: url('icons.png') no-repeat .icon0 background-position: center -153px .icon1 background-position: center 5px .icon2 background-position: center -50px .icon3 background-position: center -102px .icon4 background-position: center -312px .txtbox display: none position: absolute top: 0px right: 65px width: 150px height: 45px line-height: 45px font-size: 14px padding: 5px background-color: #6b4ec2 &:after display: block position: absolute right: -5px top: 22px content: '' width: 0 height: 0 border-width: 7px 0 7px 7px border-style: solid border-color: transparent transparent transparent #6b4ec2 .picbox display: none position: absolute top: -30px right: 65px width: 100px height: 100px padding: 5px background-color: #6b4ec2 img width: 100% height: 100% &:after display: block position: absolute right: -5px top: 50px content: '' width: 0 height: 0 border-width: 7px 0 7px 7px border-style: solid border-color: transparent transparent transparent #6b4ec2 </style>
下載地址: https://github.com/imxiaoer/FloatToolBar
補(bǔ)充:下面看下vue 側(cè)邊導(dǎo)航欄遞歸顯示 的實(shí)例代碼。
import axios from "axios"; import tabs1 from "../tab_content/tab1.vue"; import myTree from "./items.vue"; export default { data() { return { theModel: [], }; props: ["tabs"] }, components: { myTree }, methods: { tabsvalue(data){ console.log(data) this.$emit("get-data",data) } }, watch: { }, created() { axios .get("../../../static/nav.json") // .get("。。。") .then( function(response) { var arr = response.data.dActionList; var zNodes = []; var farternode = []; for (var i in arr) { if (arr[i].desktop == "0" && arr[i].parentId != null) { farternode.push(arr[i]); } if (arr[i].parentId && arr[i].desktop == "1") { zNodes.push(arr[i]); } } var childNodes = function getChildNodes( parentId, zNodes, nodes, child, parentItem ) { if (!parentId || !zNodes) return nodes; var childNode = []; for (var k in zNodes) { if (zNodes[k].parentId == parentId) { if (child) { childNode.push(zNodes[k]); } else { nodes.push(zNodes[k]); } childNodes(zNodes[k].id, zNodes, nodes, true, zNodes[k]); } } if (childNode.length > 0 && child) { parentItem.children = childNode; } return nodes; }; for (var j in farternode) { farternode[j]["children"] = []; var nodes = []; nodes = childNodes(farternode[j].id, zNodes, nodes, false, null); farternode[j].children = nodes; } console.log(farternode); console.log(nodes); this.theModel = farternode; }.bind(this) ) .catch(function(error) { console.log(error); }); console.log(this.$refs.tabsdata) } };
父組件 的js
<template> <div id="navto"> <my-tree v-for="menuItem in theModel" :key="menuItem.id" :model="menuItem" @data-tabsvalue="tabsvalue"></my-tree> </div> </template>
父組件的節(jié)點(diǎn)
import tabs from '../compont/tabs.vue' export default { name: 'treeMenu', props:["model"], data () { return { folderIcon: 'folder', isDynamicFolder: false, isOpen: false, } }, computed: { isFolder () { return !!(this.model.children && this.model.children.length) } }, watch: { isDynamicFolder () { this.isOpen = true this.folderIcon = 'folder-open' } }, methods: { tabsvalue(data){ this.$emit("data-tabsvalue",data) }, run(data){ if(!data.children){ this.tabsvalue(data) console.log(data.text); console.log(data.url) } }, toggle () { this.isOpen = !this.isOpen this.folderIcon = this.isOpen ? 'folder-open' : 'folder' } } }
子組件的js
<template> <li> <span @click="toggle"> <i :class="['icon', (isFolder || isDynamicFolder) ? folderIcon : 'file-text']"></i> <span class="mousestyle">{{ model.text}}</span> </span> <!-- <transition name="mybox" > --> <ul v-if="isOpen"> <span v-for="item in model.children" :key="item.id" @click.stop="run(item)"> <tree-menu :model="item" @data-tabsvalue="tabsvalue"> </tree-menu> </span> </ul> <!-- </transition> --> </li> </template>
子組件的節(jié)點(diǎn)
總結(jié)
以上所述是小編給大家介紹的Vue實(shí)現(xiàn)底部側(cè)邊工具欄的實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
vue.js click點(diǎn)擊事件獲取當(dāng)前元素對(duì)象的操作
這篇文章主要介紹了vue.js click點(diǎn)擊事件獲取當(dāng)前元素對(duì)象的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-08-08離線搭建vue環(huán)境運(yùn)行項(xiàng)目完整步驟
這篇文章主要給大家介紹了關(guān)于離線搭建vue環(huán)境運(yùn)行項(xiàng)目的相關(guān)資料,文中通過(guò)實(shí)例代碼以及圖文介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2023-06-06Vue如何實(shí)現(xiàn)el-table多選樣式變?yōu)閱芜x效果
這篇文章主要介紹了Vue如何實(shí)現(xiàn)el-table多選樣式變?yōu)閱芜x效果,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-05-05el-form-item?prop屬性動(dòng)態(tài)綁定不生效問(wèn)題及解決
這篇文章主要介紹了el-form-item?prop屬性動(dòng)態(tài)綁定不生效問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-07-07基于Vue實(shí)現(xiàn)頁(yè)面切換左右滑動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了基于Vue實(shí)現(xiàn)頁(yè)面切換左右滑動(dòng)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08Vue報(bào)錯(cuò)error:0308010C:digital?envelope?routines::unsupported
這篇文章主要給大家介紹了關(guān)于Vue報(bào)錯(cuò)error:0308010C:digital?envelope?routines::unsupported的解決方法,文中通過(guò)圖文將解決的辦法介紹的非常詳細(xì),需要的朋友可以參考下2022-11-11深入淺析Vue中mixin和extend的區(qū)別和使用場(chǎng)景
Vue中有兩個(gè)較為高級(jí)的靜態(tài)方法mixin和extend,接下來(lái)給大家介紹Vue中mixin和extend的區(qū)別和使用場(chǎng)景,感興趣的朋友一起看看吧2019-08-08VUE DEMO之模擬登錄個(gè)人中心頁(yè)面之間數(shù)據(jù)傳值實(shí)例
今天小編就為大家分享一篇VUE DEMO之模擬登錄個(gè)人中心頁(yè)面之間數(shù)據(jù)傳值實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10