vue 標簽動態顯示class、style(三目運算判斷、動態賦值)


 

    <div class="example1 example2"></div>
    <div :class="true?'example1':'example2'"></div>
    <div :class="{ 'example1': true }"></div>
    <div :class="['example1', {'example2':true}]"></div>

 

    <div style="width:calc(100% - 10px); color:red"></div>
    <div :style="true?{ width: 'calc(100% - 10px)', color: 'red' }:''"></div>
    <div :style="{ width: true?'calc(100% - 10px)':'200px', color: 'red' }"></div>
    <div :style="{ width: `calc(100% - ${aaaa}px)`, color: bbbb }"></div>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM