vue里面is_vue中的is

is有两种用法:

第一种就是在一些标签中像ul,ol,table等使用自定义的一些组件,浏览器的解析是有问题的,甚至报错。而添加这个属性之后就可正常使用,但是我测试是可以用的,可能是版本的问题,不知道什么原因。

第二种也是非常好用的一种,用于组件的切换,在一些导航栏上是非常好用的具体例子如下

这里是动态组件

.left{pasition:fixed;width:190px;}

.left ul li{height:40px;width:100%;margin-top:10px;background:pink;}

.right{width:500px;height:200px;position:relative;top:-250px;left:190px;background:red;}

  • v-for="tab in tabs"

    v-bind:key="tab.name"

    v-bind:class="['tab-button',{active:currentTab === tab.name}]"

    v-on:click="currentTab = tab.name"

    >

    {{ tab.item }}

v-bind:is="currentTabComponent"

class="tab">

hahahahhhhh

Vue.component('tab-zy1', {

template: '

我是zy1 页面
'

});

Vue.component('tab-zy2', {

template: '

我是zy2页面
'

});

Vue.component('tab-zy3', {

template: '

我是zy3 页面
'

});

Vue.component('tab-zy4', {

template: '

我是zy4页面
'

});

Vue.component('tab-zy5', {

template: '

我是zy5 页面
'

});

Vue.component('tab-zy6', {

template: '

我是zy6 页面
'

});

Vue.component('tab-zy7', {

template: '

我是zy7 页面
'

});

new Vue({

el: '#container',

data: {

currentTab: 'zy1',

tabs: [{name:'zy1',item:'物理资源'},{name:'zy2',item:'存储资源'} ,{name:'zy3',item:'客户端'},{name:'zy4',item:'存储资源'},{name:'zy5',item:'系统管理'},{name:'zy6',item:'性能统计'},{name:'zy2',item:'监控中心'}],

},

computed: {

currentTabComponent: function () {

return 'tab-' + this.currentTab.toLowerCase();

}

}

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值