BadGirl_Xiao

导航

vue添加class类名

<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    
</head>
<body>
<div id="app">
    <ul>
        <li v-for="item in tabs" :class="[classA, {classB: isB, classC: isC}]">
            {{ item.text }}
        </li>
    </ul>
</div>
<script type="text/javascript">
    new Vue({
        el:'#app',
        data: {
            classA: 'A',
            isB: false,
            isC: true,
            tabs: [{
                text:'巴士'
            },{
                text:'快车'
            },{
                text:'专车'
            },{
                text:'顺风车'
            },{
                text:'出租车'
            },{
                text:'代驾'
            }]
        }
    })
</script>
<style type="text/css">
    .A{
        color: red
    }
    .classC{
        text-decoration: underline;
    }
    .classB{
        font-weight: bold
    }
</style>
</body>
</html>

  

posted on 2018-05-11 17:19  BadGirl_Xiao  阅读(1122)  评论(0编辑  收藏  举报