style里面设置变量

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