相关疑难解决方法(0)

Vue 3 DefineProps 与 Types 和 ComponentObjectPropsOptions(如默认值或验证器)

从设置方法中,使用defineProps我可以使用

const props = defineProps<{tabs: Tab[]}> = ()
Run Code Online (Sandbox Code Playgroud)

Tab[]这让我可以打开类型props.tabs

但是,如果我想指定ComponentObjectPropsOptions,我相信语法是

const props = defineProps = ({
  type: Array, //can not use Tab[] here
  required: true,
  validator: ...
})
Run Code Online (Sandbox Code Playgroud)

但使用这种语法我失去了我的类型props.tabs:(

typescript vue.js

11
推荐指数
3
解决办法
4万
查看次数

标签 统计

typescript ×1

vue.js ×1