使用 Vue 3测试时有如下代码:

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

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

具体的错误信息如下:

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:vuejs/vetur/issues/2296">issue 其中有下面这段话:

If you take a look at how Evan recently vuejs/rfcs/discussions/378#discussioncomment-1158805">responded about the recommended approach going forward, it seems that volar is currently the extension of choice for vue 3.

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

选择卸载vetur,安装volar插件

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

最后,记得重启下VS Code

  • 浏览量 4526
  • 收藏 0
  • 0

所有评论(0)

加载更多