<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
.red{ color:red}
.black{color:#000}
.active{ color:red}
</style>
</head>
<body>
<div id="app">
<template v-for="(t,index) in lists">
<h1 :class="t.ca" @click="active(index)">{{ t.title }} </h1>
<div v-show="t.ca == 'active'">{{ t.content }} </div>
</template>
</div>
<script src="http://cdn.bootcss.com/vue/2.0.0-rc.7/vue.min.js"></script>
<script>
var app = new Vue({
el:'#app',
data: {
lists:null,
foo:2,
style:'color:red',
},
methods:{
nimabi:function(n)
{
alert(this.foo+10*n)
},
addItem : function(){
}
,remove:function(index)
{
this.todos.splice(index,1)
console.log(index)
},
active:function(index)
{
for(i in this.lists){
if(i == index){
this.lists[i].ca = 'active'
}else{
this.lists[i].ca = 'haha'
}
}
},
fetchData:function()
{
var lists = [{id:1,title:'nimabi',content:'xxxxxxxxxxxxxxxxxxxxxxxx'},{id:2,title:'caonima',content:'hahahahahahahahhahhahahahahahah'}];
for(i in lists)
{
lists[i].ca = "hahah"
}
this.lists = lists
}
},
created:function(){
this.fetchData()
this.lists[0].ca = 'active'
}
})
</script>
<body/>
</html>
vuejs 2.0 tabs
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 目录 环境搭建 后端2.1 数据库设计2.2 SpringBoot + Mybatis2.3 SpringBoot...
- 警告原因: Xcode升级到8.0以后,由于一些工程配置原因. 控制台警告: 解决方法: 第一步: 第二步: 第三...
- 《见字如面》昨晚回归了,延续第一季的好口碑,而且归亚蕾和何冰也惊喜回归。何冰我们都比较了解,前一段时间凭借《白鹿原...