在webstorm中输入关于vue3 Props的禁用问题

问题描述 投票:0回答:1
  • decare 道具
import { ExtractPropTypes, PropType } from 'vue'

export const Props = {
  ocrName: {
    type: String as PropType<string>,
    default: () => 'Nicky',
  },
  age: {
    type: Number as PropType<number>,
    default: () => 18,
  },
} as const

export type OcrPropsType = ExtractPropTypes<typeof Props>

  • 在.vue中使用
<script setup lang="ts">
  import { Props } from './props'
  const prop = defineProps(Props)
<script>
  • templete 不能重新输入类型,但在 vscode 中有效,在 webstorm 中禁用。

网络风暴:2023.2 EAP 打字稿:5.1.6 vue:3.3.4

typescript webstorm vue-props
1个回答
0
投票

尝试像这样使用

defineProps

<script setup lang="ts">
import { defineProps } from 'vue';

const props = defineProps<{
  prop1: number;
  prop2: string;
  ...
}>();
</script>
© www.soinside.com 2019 - 2024. All rights reserved.