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