Vue Ts 提示 ‘cannot find name Ref’ 是为什么?

新手上路,请多包涵

已经安装了 “unplugin-auto-import” 自动导入插件,这种情况还需要手动引入 Ref么?
如下:

import {Ref} from 'vue'

const message: Ref < string >= ref("123");

还是单纯的我配置插件配置的有问题。

阅读 6.8k
1 个回答

如果你是想规定类型的话可以这样写:const message = ref<string>('123')
或者

import type { Ref } from 'vue'

const message: Ref<string> = ref('123')

unplugin-auto-import目前并不能导入类型,可以看一下这个RFC:https://github.com/antfu/unpl...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题