美文网首页
vue的选项卡实现代码

vue的选项卡实现代码

作者: smallBear | 来源:发表于2018-01-24 17:48 被阅读0次

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>选项卡</title>
<script src="vue.js"></script>
<style>
.active{
color:red
}
#app ul{
width:300px;
display:flex;
height:30px;
}
ul li {
text-align:center;
list-style:none;
flex:1;
font-size:20px;
border:1px solid #000;
}
</style>
</head>
<body>
<div id="app">
<ul>
<li @click="toggle($index ,tab.view)" v-for="tab in tabs" :class="{active:active==$index}">
{{tab.type}}
</li>
</ul>
<component :is="currentView"></component>
</div>
<script>
Vue.component('child1', {
template: "<p>this is child1</p>"
})
Vue.component('child2', {
template: "<p>this is child2</p>"
})
Vue.component('child3',{
template:<p>this is child 33</p>
})
new Vue({
el: "#app",
data: {
active: 0,
currentView: 'child1',
tabs: [
{
type: '选项一',
view: 'child1'
},
{
type: '选项二',
view: 'child2'
},
{
type: '选项三',
view: 'child3'
}
]
},
methods: {
toggle(index, view){
this.active = index
this.currentView = view
}
}
})
</script>
</body>
</html>

相关文章

  • vue的选项卡实现代码

    选项卡 .active{color:red}#app ul{width...

  • 如何用Vue实现选项卡

    今天我想用Vue实现选项卡,去百度搜了一搜也没有什么实际的,可直接帮助大家实现的代码,那今天我就给大家看下我写好的...

  • vue饿了么移动端app总结第一篇

    使用的是vue-cli 2.x脚手架 一、头部组件的实现 二、使用vue-router实现选项卡 项目的地址: 一...

  • parcel+vue

    今天主要说的是用parcel+vue实现一个打包js选项卡的功能 每一张图片下面都贴心的给您附上了源代码 1.首先...

  • vue 实现选项卡

    html 部分: js部分: 还有一种情况是点击选项卡直接切换路由,通过路由导航直接改变页面。

  • 选择卡

    运用seg实现选项卡 效果类似于 代码如下 seg 事件处理- (void)segmentedValueChang...

  • 订单界面实现

    订单部分代码 (1)订单界面整体代码OrderV.vue (2)底部DockerV.vue 实现界面

  • 使用ViewPager+Fragment实现选项卡切换效果

    实现效果 本实例主要实现用ViewPage和Fragment实现选项卡切换效果,选项卡个数为3个,点击选项卡或滑动...

  • 11Vue.js实现全选与反选

    vue实现全选与反选 示例效果: 实现代码:

  • v-for列表渲染

    vue中对json数据格式的渲染,实现选项卡的功能 利用v-for列表渲染 HTML结构部分 script部分 v...

网友评论

      本文标题:vue的选项卡实现代码

      本文链接:https://www.haomeiwen.com/subject/guouaxtx.html