dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
39.93k stars 3.62k forks source link

vue3-slot结合v-if判断不生效 #4486

Open chenchenpp opened 1 year ago

chenchenpp commented 1 year ago

问题描述 定义了一个组件,设置了右插槽,通过v-if判断使用右slot,正常理解此判断应该能够控制插槽显示隐藏:

<Amount>
  <template #right v-if="couponitem.voucherType == '5'">
    <text >折</text>
  </template>
</Amount>

预期结果 希望能够能够正常判断隐藏显示

实际结果 image 当voucherType不是5的情况下,还是正常显示出来了

XianZheCwx commented 1 year ago

我也遇到了这个问题,在Vue里,这种方法明显是支持的,但在uniapp不行。 image image

XianZheCwx commented 1 year ago

令人感到疑惑的是,在uniapp插槽中触发多根节点包裹时却生效了 image image

yurj26 commented 10 months ago

感谢反馈,只有具名插槽内容为单根节点时,template 的 v-if 才会有问题,后续会修复。