微信小程序wxml文件里的if语句多执行了怎么处理

img

我已经把发消息的人的openid绑定了,我打算判断获取的内容的发送者和账号使用者进行判断,然后把语句左右分开,可却只在左边执行,或者说只在一个view执行完全部语句,我确认过保存的两句话openid不一样。这样是出现什么问题了。

代码:

  <block wx:key wx:for='{{content}}' wx:for-index="index">

    <view wx:if="{{item.speaker!=getApp().globalData.oppenid}}"  id='msg-{{index}}' style='display: flex; padding: 2vw 11vw 2vw 2vw;'>
      <view style='width: 11vw; height: 11vw;'>
        <image style='width: 11vw; height: 11vw; border-radius: 10rpx;' src='../../images/tabs/message.png'></image>
      </view>
      <view style='width: 4vw; height: 11vw; margin-left: 0.5vw; display: flex; align-items: center; z-index: 9;'>
      </view>
      <view class='leftMsg'>{{item.content}}</view>
    </view>

    <view wx:else id='msg-{{index}}' style='display: flex; justify-content: flex-end; padding: 2vw 2vw 2vw 11vw;'>
      <view class='rightMsg'>{{item.content}}</view>
      <view style='width: 4vw; height: 11vw; margin-right: 0.5vw; display: flex; align-items: center; z-index: 9;'>
      </view>
      <view style='width: 11vw; height: 11vw;'>
        <image style='width: 11vw; height: 11vw; border-radius: 10rpx;'src='../../images/tabs/home-active .png'></image>
      </view>
    </view>
  </block>

img

这是我学习他人的技术:https://blog.csdn.net/java558/article/details/86001064

多几个if的view 不用wx:else效果会更好

getApp().globalData.oppenid 变量名错了吧,应该是 openid

img