在小程序中使用下拉菜单组件的时候,会显示出好几个警告: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>
网友评论