vue component标签_vue标签页(Tabs)最佳实践

2f70be6f838e9c4e76442f607c7d34e3.png

vue中Tabs的各种花式写法,官网也没有也给最佳实践。在实时性比较高的一些系统中,组件切换时可能数据已经更新了,这时候就需要组件动态载入。

<template>
  <div class="container">
    <el-tabs v-model="active">
      <el-tab-pane
        v-for="item in tabs"
        :key="item.id"
        :label="item.title"
      >
        <component
            v-bind:is="active === item.id ? item.component : false"
          ></component>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script type="text/ecmascript-6">
export default {
  name: 'demo',
  components: {},
  props: {},
  data () {
    return {
      active : 0,
      tabs: [{
          title: '标签a',
          id: 0,
          component: () => import('./components/a')
        }, {
          title: '标签b',
          id: 1,
          component: () => import('./components/b')
      }, {
          title: '标签c',
          id: 2,
          component: () => import('./components/c')
      }, {
        title: '标签d',
        id: 3,
        component: () => import('./components/d')
      }]
    }
  }
}
</script>

写 Vue一个多月了,相比React,vue很多功能的实现都非常简单,开发速度高效。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值