vue組件tabbar使用方法詳解
更新時間:2018年11月06日 15:28:42 作者:wandoumm
這篇文章主要為大家詳細介紹了vue組件tabbar使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue組件tabbar的具體使用方法,供大家參考,具體內(nèi)容如下
1.App.vue
<!-- 入口文件 --> <template> <div id="app"> <!-- 視圖層 --> <router-view></router-view> <!-- 底部選項卡 --> <tabbar @on-index-change="onIndexChange" v-if="tabbarShow"> <tabbar-item selected link="/home"> <img slot="icon" src="./assets/img/ic_tab_home_normal.png"> <img slot="icon-active" src="./assets/img/ic_tab_home_active.png"> <span slot="label">首頁</span> </tabbar-item> <tabbar-item show-dot link="/audioBook"> <img slot="icon" src="./assets/img/ic_tab_subject_normal.png"> <img slot="icon-active" src="./assets/img/ic_tab_subject_active.png"> <span slot="label">書影音</span> </tabbar-item> <tabbar-item badge="2" link="/mine"> <img slot="icon" src="./assets/img/ic_tab_profile_normal.png"> <img slot="icon-active" src="./assets/img/ic_tab_profile_active.png"> <span slot="label">我的</span> </tabbar-item> </tabbar> </div> </template> <script> // 引入 vux tabbar 組件 import { Tabbar, TabbarItem } from 'vux' // 引入 vuex 的兩個方法 import {mapGetters, mapActions} from 'vuex' export default { name: 'app', components:{ Tabbar, TabbarItem }, data() { return { select:"Home" } }, // 計算屬性 computed:mapGetters([ // 從 getters 中獲取值 'tabbarShow' ]), // 監(jiān)聽,當路由發(fā)生變化的時候執(zhí)行 watch:{ $route(to,from){ if(to.path == '/' || to.path == '/home' || to.path == '/audioBook' || to.path == '/mine'){ /** * $store來自Store對象 * dispatch 向 actions 發(fā)起請求 */ this.$store.dispatch('showTabBar'); }else{ this.$store.dispatch('hideTabBar'); } } }, methods: { onIndexChange (newIndex, oldIndex) { console.log(newIndex, oldIndex); } } } </script> <style lang="less" scoped> </style>
2.效果圖
3.其他情況
<template> <div class="weui-tab"> <div class="weui-tab__panel"> <p v-for="i in 100">{{i}}</p> </div> <tabbar> <!--use v-link--> <tabbar-item v-link="{path:'/component/cell'}"> <img slot="icon" src="../assets/demo/icon_nav_button.png"> <span slot="label">Wechat</span> </tabbar-item> <!--use http link--> <tabbar-item show-dot link="https://vux.li"> <img slot="icon" src="../assets/demo/icon_nav_msg.png"> <span slot="label">Message</span> </tabbar-item> <!--use vue-router link--> <tabbar-item selected link="/component/cell"> <img slot="icon" src="../assets/demo/icon_nav_article.png"> <span slot="label">Explore</span> </tabbar-item> <!--use vue-router object link--> <tabbar-item :link="{path:'/component/cell'}"> <img slot="icon" src="../assets/demo/icon_nav_cell.png"> <span slot="label">News</span> </tabbar-item> </tabbar> </div> </template> <script> import { Tabbar, TabbarItem } from 'vux' export default { ready () { document.querySelector('body').style.height = '100%' document.querySelector('html').style.height = '100%' document.querySelector('#app').style.height = '100%' }, components: { Tabbar, TabbarItem } } </script>
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue調(diào)試工具vue-devtools的安裝全過程
這篇文章主要介紹了vue調(diào)試工具vue-devtools的安裝全過程,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-06-06解決創(chuàng)建vue項目后沒有vue.config.js文件的問題
這篇文章給大家主要介紹如何解決創(chuàng)建vue項目后沒有webpack.config.js(vue.config.js)文件,文中有詳細的解決方法,感興趣的朋友可以參考閱讀下2023-07-07Vue項目如何在js文件里獲取路由參數(shù)及路由跳轉(zhuǎn)
日常業(yè)務(wù)中路由跳轉(zhuǎn)的同時傳遞參數(shù)是比較常見的,下面這篇文章主要給大家介紹了關(guān)于Vue項目如何在js文件里獲取路由參數(shù)及路由跳轉(zhuǎn)的相關(guān)資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2024-01-01vue 1.0 結(jié)合animate.css定義動畫效果
本文分步驟給大家介紹了Vue 1.0自定義動畫效果,vue1.0代碼結(jié)合animate.css定義動畫,頁面一定要引入animate.cdd,具體實例代碼大家參考下本文2018-07-07Vue3+Canvas實現(xiàn)坦克大戰(zhàn)游戲(二)
本文主要給大家講解一下子彈擊中物體、物體銷毀、敵方坦克構(gòu)建生成、運動算法、爆炸效果、以及障礙物的生成,感興趣的小伙伴可以了解一下2022-03-03vue-router中 query傳參和params傳參的使用和區(qū)別講解
這篇文章主要介紹了vue-router中 query傳參和params傳參的使用和區(qū)別講解,本文結(jié)合示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧2024-01-01