defineslots用法 <defineSlots> 是 Vue 3.3 新增的一个特性,用于定义具名插槽。这个特性使得在子组件中可以给插槽命名并在父组件中使用这些名称来使用插槽,增强了代码的可读性和可维护性。<defineSlots> 的基本用法如下:在子组件中,使用 <slot> 标签定义具名插槽,并使用 slot 属性给插槽命名:复制代码<slot ...
Describe the bug 使用 vue-tsc 生成 .vue 的声明文件,vue 版本为 3.2,使用到了 defineSlots,但是生成出来 slot 的类型为 void 复现步骤: pnpm tsc 结果: Reproduction https://github.com/shens3/define-slots-demo System Info System: OS: macOS 13.2.1 CPU: (6) x6
这就需要使用 Generic: constprops=defineProps<{list:T[],// 泛型的方式list2:number[],// 只能是 number 类型的数组list3:Array<any>,// 任意类型的数组name:string,person:{name:string}}>()console.log('props-ts:\n',props) 这里定义了几个属性,第一个使用了泛型,第二个是 number[],第三个是任...