The applet wx:else prompts Bad attr `wx

 Question: The following wx:if in wx:for, wx:else will report this error: Bad attr 'wx

  <scroll-view class="scroll1" scroll-x enable-flex="true">

        <view wx:if="{
   
   {playlist.length>0}}" class="item" wx:for="{
   
   {playlist}}" >
          <image class="item-img" src="{
   
   {item.song.al.picUrl?item.song.al.picUrl:'/static/images/recommendSong/02.jpg'}}"></image>
          <text class="item-value">{
   
   {item.song.al.name}}</text>
        </view>
        <view wx:else> 暂无播放记录</view>

      </scroll-view>

 solve:

WX:FOR and WX:IF are mentioned under the same label: the priority of for is higher than that of if, wx:if and wx:for cannot be written on the same label , according to the following code personality, add a block package :

      <scroll-view class="scroll1" scroll-x enable-flex="true">
        <block wx:if="{
   
   {playlist.length>0}}">
          <view  class="item" wx:for="{
   
   {playlist}}" >
            <image class="item-img" src="{
   
   {item.song.al.picUrl?item.song.al.picUrl:'/static/images/recommendSong/02.jpg'}}"></image>
            <text class="item-value">{
   
   {item.song.al.name}}</text>
          </view>
        </block>
        <view wx:else> 暂无播放记录</view>
      </scroll-view>

Guess you like

Origin blog.csdn.net/LlanyW/article/details/132129228