Vue Tab选项卡案例
Posted 拿红罗卜钓鱼
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vue Tab选项卡案例相关的知识,希望对你有一定的参考价值。
点击不同的标题显示出相应的图片
代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../js/vue.js" type="text/javascript" charset="UTF-8"></script>
<style type="text/css">
.parts span {
display: inline-block;
width: 100px;
height: 20px;
border: 1px solid #000000;
}
.parts .active {
border: 1px solid orange;
}
.block {
width: 100px;
min-height: 100px;
border: 1px solid #ddd;
}
</style>
</head>
<body>
<div id="app">
<div class="parts">
<span v-on:click="func('A');" v-bind:class="{'active':(active=='A') }">apple(苹果)</span>
<span v-on:click="func('B');" v-bind:class="{'active':(active=='B') }">orange(橘子)</span>
<span v-on:click="func('C');" v-bind:class="{'active':(active=='C') }">lemon(柠檬)</span>
</div>
<div class="block block1" v-if="block=='A'">
<img src="../img/苹果.png">
</div>
<div class="block block1" v-if="block=='B'">
<img src="../img/橘子.png">
</div>
<div class="block block1" v-if="block=='C'">
<img src="../img/柠檬.png">
</div>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
active: 'C',
block: 'C'
},
methods: {
func: function (event) {
this.active = event;
this.block = event;
}
}
});
</script>
</body>
</html>
效果图
以上是关于Vue Tab选项卡案例的主要内容,如果未能解决你的问题,请参考以下文章