亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Vue可自定義tab組件用法實(shí)例

 更新時(shí)間:2019年10月24日 16:34:40   作者:axel10  
在本篇文章里小編給大家分享了關(guān)于Vue可自定義tab組件用法實(shí)例以及相關(guān)知識(shí)點(diǎn),需要的朋友們參考下。

在工作中我們常常要用到tab組件,如果有用第三方組件庫(kù)的話一般都會(huì)有這個(gè)組件,但如果沒有使用第三方組件庫(kù),或者想要自定義tab,那么或許這個(gè)無依賴的tab組件將會(huì)極大地節(jié)約你的開發(fā)時(shí)間。

如何使用?

1. 首先先安裝:

npm i vue-cus-tabs -S

2. 在new vue之前引入樣式并use一下VueCusTab:

import 'vue-cus-tabs/style/index.css'
import { installCusTabs } from 'vue-cus-tabs';
Vue.use(installCusTabs);

3. 在代碼中引入組件:

<CusTabWrap>
   <template v-slot:tabBar>
    <CusTabBar :style="{'height':'50px'}">
     <CusTabItem v-for="item in tabItems" :key="item.title">
      {{item.title}}
     </CusTabItem>
    </CusTabBar>
   </template>

   <template v-slot:tabContainer>
    <CusTabContainer>
     <CusTabContainerItem v-for="item in tabItems">
      <ul>
       <li v-for="data in item.data">
        {{data.title}}
       </li>
      </ul>
     </CusTabContainerItem>
    </CusTabContainer>
   </template>
  </CusTabWrap>
import { TabController } from 'vue-cus-tabs';
  import Vue from 'vue'

  

  export default class Test extends Vue{
   public tabItems = [
    { title: '新聞', type: 'list', data: [{ img: '', title: 'list item  title' }] },
    { title: '視頻', type: 'block', data: [{ video: '', title: 'list item   title' }] },
    { title: '視頻1', type: 'block', data: [{ video: '', title: 'list item  title' }] },
   ];
   public tabController?: TabController;
   public mounted() {
    
    // 創(chuàng)建控制器
    this.tabController = new TabController({ data: this.tabItems, tabScroll: true, initIndex: 1 });
   }
  }

4. 啟動(dòng)Vue Cli的serve,即可看到成果。

整個(gè)組件的設(shè)計(jì)思路借鑒了flutter的tabs組件,數(shù)據(jù)的渲染交由vue完成,之后的tab控制由TabController實(shí)例來完成。

github: https://github.com/axel10/cus-tabs

npm: https://www.npmjs.com/package/vue-cus-tabs

在線演示:https://vue-cus-tabs-axel10.now.sh

以上就是本次介紹的相關(guān)知識(shí)點(diǎn)內(nèi)容,感謝大家的學(xué)習(xí)和對(duì)腳本之家的支持。

相關(guān)文章

最新評(píng)論