微信小程序自定义组件用slot插入cover-view的问题

2021年3月15日11:52:25 发表评论
微信搜一搜 ts小陈

自定义组件使用slot嵌套cover-view 时,自定义组件的 slot 及其父节点暂不支持通过 wx:if 控制显隐,否则会导致 cover-view 不显示。例如:

微信小程序自定义组件用slot插入cover-view的问题

  1. <!-- ComponentA -->
  2. <cover-view wx:if="{{ status === 'fail' }}">
  3.       <slot name="before"></slot>
  4.       <cover-view>{{ failDesc }}</cover-view>
  5.       <slot name="after"></slot>
  6. </cover-view>
  7.  <!-- PageA -->
  8.  <ComponentA>
  9.      <cover-image src="xxx.png" slot="before"/>
  10.     <cover-view slot="after">hellow word</cover-view>
  11.  </ComponentA>

上面自定义组件ComponentA因为使用了slot来嵌套cover-view,而其父节点使用了wx:if控制显隐,导致在真机环境slot的cover-image和cover-view内容不显示。

小陈号卡
ts小陈

发表评论(不允许含有网址!)

:?: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :cry: :mrgreen: :neutral: :razz:

已登录用户不需要填写以下内容