美文网首页
vantWeapp报错警告slot "" is not foun

vantWeapp报错警告slot "" is not foun

作者: 新篇章 | 来源:发表于2022-03-29 09:04 被阅读0次

在小程序中使用下拉菜单组件的时候,会显示出好几个警告:slot "" is not found (for component "miniprogram_npm/@vant/weapp/popup/index);查看miniprogram_npm中的popup组件里面有默认slot,但是因为wx:if 初始值为false导致初始解析时跳过,所以会弹出警告,解决办法再下面加个wx-else的默认插槽;如下:

<view
  wx:if="{{ inited }}"
  class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safe: safeAreaInsetBottom, safeTop: safeAreaInsetTop }]) }}"
  style="{{ computed.popupStyle({ zIndex, currentDuration, display, customStyle }) }}"
  bind:transitionend="onTransitionEnd"
>
  <slot />
  <van-icon
    wx:if="{{ closeable }}"
    name="{{ closeIcon }}"
    class="close-icon-class van-popup__close-icon van-popup__close-icon--{{ closeIconPosition }}"
    bind:tap="onClickCloseIcon"
  />
</view>
//添加默认插槽
<view wx:else style="display: none;">
  <slot></slot>
</view>

相关文章

网友评论

      本文标题:vantWeapp报错警告slot "" is not foun

      本文链接:https://www.haomeiwen.com/subject/aulvjrtx.html