style里面设置变量

时间:2020-06-09 18:10:19   收藏:0   阅读:339

 

1、在style里面添加变量

*适用于组件统一调整样式

//html 示例

1 <div class="headerBox">
2     <p class="headerContent"></p>    
3 </div>

//css 示例

.headerBox{
  --bgc:#ffffff;  
}
.headerContent{
  background-color:var(--bgc);  
}

 

2、style内联样式中添加方法

//html 示例

<div :style="getStyle()"></div>

//medthods 示例

getStyle(){
  return ‘color:red‘  
}

 

原文:https://www.cnblogs.com/Li--gm/p/13073850.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!