1、通过class绑定

<div :class="{'div-class': this.align == 'center'}"></div>

对应的css

.div-class {
  height: auto;  
}

其中this.align可放在data或props中

2、通过三元表达式

<div :style="{ 'height': this.align=='center' ? 'auto' : '' }"></div>

3、通过计算属性

<div :align="align" :style="getLocality"></div>

在computed中写对应的计算:

computed: {
        getLocality() {
          if(this.align === "center") {
            return "height: auto"
          }
        }
    },

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
猜你喜欢
  • 2021-11-12
  • 2022-02-20
  • 2022-12-23
相关资源
相似解决方案