偶是小菜鸟
偶是小菜鸟
  • 发布:2019-02-27 17:05
  • 更新:2019-05-24 15:36
  • 阅读:4318

动态style绑定

分类:uni-app

<div v-bind:class="classObject"></div>

data() {
return {
isActive: true,
error: null
}
},
computed: {
classObject: function () {
return {
active: this.isActive && !this.error,
'text-danger': this.error && this.error.type === 'fatal'
}
}
}
vue中,内联样式可以通过这种方式来完成。

uni-app中,官方写法如下:
<view :style="{color:color}" />
那么,uni-app中不能采用跟vue同样的写法吗?
尝试使用vue方式写:
<view class="run_one" :style="getRunOneBg"></view>
computed: {
getRunOneBg() {
return {
background: 'url(' + this.runOneBg + ') 0 0/100% 100% no-repeat'
};
}
},
结果:
<viewclass="_view fdfd28ca run_one"style=" [object Object]"role=""aria-label=""></view>

2019-02-27 17:05 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

哈库拉玛塔塔

哈库拉玛塔塔 - 简单又好吃

新发现问题,动态改颜色啥的这些样式没问题,如果改高度会出现不渲染的bug data中设置一个随机数 定时更新下随机数的值会触发高度渲染。狗的不行。。

该问题目前已经被锁定, 无法添加新回复