vue2 slot占位插槽默认值不显示undefiend

2024-03-05  本文已影响0人  w_wx_x

问题点:vue版本问题,当vue > 2.6.12时就会出现,vue-template-compiler需要与vue版本同步

解决方法
  1. 把vue与vue-template-compiler版本降低到2.6.12及以下
  2. 用v-if v-else 语法替换原本内容
// 原来写法
<slot name="title"> default title </slot>

// 兼容处理写法
<slot name="title" v-if=‘$slots.title’></slot>
<template v-else> default title </template>
上一篇 下一篇

猜你喜欢

热点阅读