0
点赞
收藏
分享

微信扫一扫

关于微信小程序style动态绑定问题

灯火南山 2022-04-13 阅读 80

直接书写,报红但是生效

<view class="action border-custom"  wx:if="{{isCustom}}" style="width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)">
  <text class="icon-back" bindtap="BackPage"></text>
  <text class="icon-homefill" bindtap="toHome"></text>
</view>

直接v-bind(缩写为": "),不报红,但是失效

    <view class="action border-custom"  wx:if="{{isCustom}}" :style="width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)">
      <text class="icon-back" bindtap="BackPage"></text>
      <text class="icon-homefill" bindtap="toHome"></text>
    </view>

解决办法,绑定后,采用vue写法

    <view class="action border-custom"  wx:if="{{isCustom}}" :style="width:{Custom.width}px;height:{Custom.height}px;margin-left:calc(750rpx - {Custom.right}px)">
      <text class="icon-back" bindtap="BackPage"></text>
      <text class="icon-homefill" bindtap="toHome"></text>
    </view>
举报

相关推荐

0 条评论