组件的行内样式不能有变量吗 ?

小程序 文章 2020-09-02 15:41 973 0 全屏看文

AI助手支持GPT4.0

组件的行内样式不能有变量吗 ?Can't the inline style of the component have variables?

组件的行内样式不能有变量吗 ?
     "{{backgroundColor: styles.backgroundColor}}">       view>其中styles为:{   backgroundColor:    this.data.backgroundColor}  这样就会报错:bad attr    `style`    with message  

"{{backgroundColor: styles.backgroundColor }}"> View > where styles is: {backgroundColor: this.data.backgroundColor }This will result in an error: bad attr 'style' with message

回答:

丶晓晓晓包:

background-color不要写在{{}}}里面,里面写变量就行

?:

class="{{showId==1?'active':''}}"

微喵网络:

弄一个 [ 能复现问题的简单的 ] 代码片段

https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

-EOF-

AI助手支持GPT4.0