<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#root input{
padding:5px;
margin:5px;
}
#root input.active{
background:red;
}
#root div{
width:600px;
height:200px;
background:yellow;
}
</style>
<script src="lib/vue.js"></script>
</head>
<body>
<div id="root">
<input type="button"
:class="{active:index===i}"
v-for="(item,i) in newsList"
@click="index=i"
:value="item.type"/>
<div v-show="index===i" v-for="(item,i) in newsList">
<p v-for="info in item.arr">
<a :href="info.newsHref">{{info.newsTitle}}</a>
</p>
</div>
</div>
</body>
<script>
new Vue({
el:"#root",
data:{
index:0,// 选 中项
newsList:[
{
type:"娱乐",
arr:[
{
newsTitle:"许绍洋与交往7年女友分手,43岁的他黯然搬离昔日爱巢",
newsHref:"https://new.qq.com/omn/20200318/20200318A01CN300.html"
},
{
newsTitle:"许绍洋与交往7年女友分手,43岁的他黯然搬离昔日爱巢2222",
newsHref:"https://new.qq.com/omn/20200318/20200318A01CN300.html"
}
]
},{
type:"体育",
arr:[
{
newsTitle:"中国职业足坛首例!中甲梅州巴西球员确诊新冠",
newsHref:"http://sports.qq.com/a/20200318/018486.htm"
},
{
newsTitle:"中国职业足坛首例!中甲梅州巴西球员确诊新冠222222",
newsHref:"http://sports.qq.com/a/20200318/018486.htm"
}
]
},{
type:"财经",
arr:[
{
newsTitle:"一个留观酒店经理的记“疫”:这一次,希望酒店空荡荡",
newsHref:"https://new.qq.com/omn/20200318/20200318A0E7ZX00.html"
},
{
newsTitle:"一个留观酒店经理的记“疫”:这一次,希望酒店空荡荡22222",
newsHref:"https://new.qq.com/omn/20200318/20200318A0E7ZX00.html"
}
]
}
]
}
})
</script>
</html>