Vue 动态绑定样式(v-bind:style) 中对带划线(-)的属性赋值

有时在项目中需要给动态绑定style中的一些带划线( - )的属性进行赋值,这时因为字符的原因会出现编译错误

错误示范:

<view class="statusBar" :style="{margin-top: statusBarHeight}"></view>

正确示范:

<view class="statusBar" :style="{marginTop: statusBarHeight}"></view>

statusBarHeight为Vue实例中data的变量

posted @ 2021-03-31 15:29  㭌(mou)七  阅读(370)  评论(0)    收藏  举报