码迷,mamicode.com
首页 > 其他好文 > 详细

vue 动态样式

时间:2019-04-26 22:29:36      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:tab   方法   big   运算   list   eid   三元   active   idt   

<p :style="{width:‘4px‘,height: ‘24px‘,background: ‘#f7ce51‘}"></p>
<p:style="{height: ‘400px‘,‘overflow-y‘: ‘auto‘,‘background-color‘: ‘#f3f3f3‘,padding: ‘15px‘}"></p>

三元运算符判断
<div :style="{ ‘opacity‘: !editableCheckNum ? 0.5 : 1 }">555</div>

动态设置class
<div :class="activeMachineId === machineItem.machineId?‘activeStyle‘:‘machineBar‘" v-for="(machineItem,machineIndex) in machineList" @click="clickMachineEvent">
    <p>{{machineItem.name}}</p>
    <p :style="machineStatusStyle(machineItem.status)"></p>
</div>


方法判断
<div class="machineBigBar machineList">
    <div class="machineBar" v-for="(machineItem,machineIndex) in processItem.machineList" :key="machineIndex">
        <p>{{machineItem.name}}</p>
        <p :style="machineStatusStyle(machineItem.status)"></p>
    </div>
</div>

 
methods:{
    machineStatusStyle(e){
        console.log(‘值‘,e)
        if(e === 1){
            return {
                width:‘14px‘,height:‘16px‘,
                background:"url(‘/src/images/time.png‘) no-repeat center",
                marginLeft: ‘10px‘
            }
        }else if(e === 2){
            return {
                width:‘14px‘,height:‘16px‘,
                background:"url(‘/src/images/time.png‘) no-repeat center",
                marginLeft: ‘10px‘
            }
        }else if(e === 3){
            return {
                width:‘14px‘,height:‘16px‘,
                background:"url(‘/src/images/time.png‘) no-repeat center",
                marginLeft: ‘10px‘
            }
        };
    }
}

  

vue 动态样式

标签:tab   方法   big   运算   list   eid   三元   active   idt   

原文地址:https://www.cnblogs.com/web-zqk/p/10776797.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!