ホームページ  >  記事  >  ウェブフロントエンド  >  vue mint-ui タブバー コンポーネントの使用手順の詳細な説明

vue mint-ui タブバー コンポーネントの使用手順の詳細な説明

php中世界最好的语言
php中世界最好的语言オリジナル
2018-05-14 10:14:595150ブラウズ

今回は、vue mint-ui tabbar コンポーネントを使用する手順について詳しく説明します。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]">
      主页
    </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]">
      微社区
    </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为外面页面传入的值selected
      message:this.selected,
    //这里使用的icon图标为图片,所以需要加图片改变的传入,若使用阿里图标,则不用加
      atabs:this.tabs,
    }
  },
  props:{
    selected: String,
    tabs:Array,
  },
  watch: {
    message: function (val, oldVal) {
      // 这里就可以通过 val 的值变更来确定去向
      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>
タブバーコンポーネントを使用する必要があるページにコンポーネント

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を導入します

追加:

mint-ui - タブバーの例

インポート

オンデマンドで導入:

<tabbar :selected="selected" :tabs=&#39;tabs&#39;></tabbar>
グローバル インポート: グローバル インポート後に再度インポートする必要はありません
import { Tabbar, TabItem } from 'mint-ui';
Vue.component(Tabbar.name, Tabbar);
Vue.component(TabItem.name, TabItem);
この記事の事例を読んだ後は、この方法を習得したと思います。さらに興味深い情報については、他の関連記事に注目してください。 PHP中国語ウェブサイトです!

推奨書籍:

JS Baidu検索ボックスエフェクト機能実装事例の詳細説明

jQuery.i18nに基づくWebフロントエンド国際化実装

以上がvue mint-ui タブバー コンポーネントの使用手順の詳細な説明の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。