vue mint-ui tabbar變組件使用
新建tabbar.vue
<template>
<mt-tabbar v-model="message" fixed>
<mt-tab-item id="MainPage">
<img slot="icon" :src="this.atabs[0]">
主頁(yè)
</mt-tab-item>
<mt-tab-item id="ShoppingList">
<img slot="icon" v-bind:src="this.atabs[1]">
積分商城
</mt-tab-item>
<mt-tab-item id="GroupList">
<img slot="icon" v-bind:src="this.atabs[2]">
微社區(qū)
</mt-tab-item>
<mt-tab-item id="UserCenter">
<img slot="icon" v-bind:src="this.atabs[3]">
我的
</mt-tab-item>
</mt-tabbar>
</template>
<script>
export default {
data(){
return{
//選中的tabbar值message為外面頁(yè)面?zhèn)魅氲闹祍elected
message:this.selected,
//這里使用的icon圖標(biāo)為圖片,所以需要加圖片改變的傳入,若使用阿里圖標(biāo),則不用加
atabs:this.tabs,
}
},
props:{
selected: String,
tabs:Array,
},
watch: {
message: function (val, oldVal) {
// 這里就可以通過(guò) val 的值變更來(lái)確定去向
switch(val){
case 'MainPage':
this.$router.push('/mainpage');
break;
case 'ShoppingList':
this.$router.push('/shoppinglist');
break;
case 'GroupList':
this.$router.push('/grouplist');
break;
case 'UserCenter':
this.$router.push('/usercenter');
break;
}
}
},
}
</script>
在需要使用tabbar組件的頁(yè)面
引入組件
import tabbar from '../../components/tabbar'
export default {
components:{tabbar},
data(){
return{
selected:"ShoppingList",
tabs:[require("../../assets/images/icon/zhuye.png"),require("../../assets/images/icon/icon42-1.png"),
require("../../assets/images/icon/weuquan1.png"),require("../../assets/images/icon/huijia.png")],
}
},
}
html中
<tabbar :selected="selected" :tabs='tabs'></tabbar>
補(bǔ)充:
mint-ui —— tabbar示例
Import
按需引入:
import { Tabbar, TabItem } from 'mint-ui';
Vue.component(Tabbar.name, Tabbar);
Vue.component(TabItem.name, TabItem);
全局導(dǎo)入:全局導(dǎo)入后不用再導(dǎo)入
importMintfrom'mint-ui' import'mint-ui/lib/style.css' Vue.use(Mint);
總結(jié)
以上所述是小編給大家介紹的vue mint-ui tabbar變組件使用,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- 在vue項(xiàng)目中安裝使用Mint-UI的方法
- vue.js整合mint-ui里的輪播圖實(shí)例代碼
- vue使用mint-ui實(shí)現(xiàn)下拉刷新和無(wú)限滾動(dòng)的示例代碼
- vue基于mint-ui的城市選擇3級(jí)聯(lián)動(dòng)的示例
- vue mint-ui 實(shí)現(xiàn)省市區(qū)街道4級(jí)聯(lián)動(dòng)示例(仿淘寶京東收貨地址4級(jí)聯(lián)動(dòng))
- vue學(xué)習(xí)之mintui picker選擇器實(shí)現(xiàn)省市二級(jí)聯(lián)動(dòng)示例
相關(guān)文章
Vue3使用router,params傳參為空問(wèn)題
這篇文章主要介紹了Vue3使用router,params傳參為空問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2025-04-04
vue項(xiàng)目中向數(shù)組添加元素的3種方式
這篇文章主要給大家介紹了關(guān)于vue項(xiàng)目中向數(shù)組添加元素的3種方式,在Vue中添加元素到數(shù)組非常簡(jiǎn)單,文中通過(guò)代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-10-10
解決vue項(xiàng)目運(yùn)行npm run serve報(bào)錯(cuò)的問(wèn)題
這篇文章主要介紹了解決vue項(xiàng)目運(yùn)行npm run serve報(bào)錯(cuò)的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-10-10
vue3中使用highlight.js實(shí)現(xiàn)代碼高亮顯示的代碼示例
代碼高亮是在網(wǎng)頁(yè)開(kāi)發(fā)中常見(jiàn)的需求之一,它可以使代碼在頁(yè)面上以不同的顏色或樣式進(jìn)行突出顯示提高可讀性,這篇文章主要介紹了vue3中使用highlight.js實(shí)現(xiàn)代碼高亮顯示的相關(guān)資料,需要的朋友可以參考下2025-04-04

