使用Vue3测试时有如下代码:

<script lang="ts" setup="props">
  import HelloWorld from './components/HelloWorld.vue'
</script>
<template>
  <HelloWorld/>
</template>

简单的代码附件了一些看着不爽的提示,虽然不影响正常运行:
vue3_error.png

具体的错误信息如下:

import HelloWorld from './components/HelloWorld.vue'
</script>

<template>
  <HelloWorld/>
import HelloWorld
import HelloWorld
'HelloWorld' is declared but its value is never read.Vetur(6133)
Module '"/Volumes/Work/Vue3/x-ui/src/components/HelloWorld.vue"' has no default export.Vetur(1192)

从错误提示可以看到关键字_Vetur_,来看下这是何方神圣:

官网醒目的位置:
Vue tooling for VS Code.
vetur是一个vscode插件,用于为.vue单文件组件提供代码高亮以及语法支持

再继续翻,找到了个issue:issue 其中有下面这段话:

If you take a look at how Evan recently responded about the recommended approach going forward, it seems that volar is currently the extension of choice for vue 3.

那既然官方推荐 _volar_那肯定要去看下,简单的说volar是vetur的升级版本,提供了更牛叉的功能并有更好的TS支持。

于是……

选择卸载vetur,安装volar插件

于是……,世界都清爽了好多

最后,记得重启下VS Code

标签: none

添加新评论