vue 動態樣式
阿新 • • 發佈:2019-04-27
proc 16px highlight ima event RoCE over table ===
<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 動態樣式