首页 > 其他 > 详细

vue添加class类名

时间:2018-05-11 18:27:11      阅读:167      评论:0      收藏:0      [点我收藏+]
<!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>

  

vue添加class类名

原文:https://www.cnblogs.com/AmbiguousMiao/p/9025724.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!