nuxt.js 生成的默认文件 components/Logo.vue 源码大概如下:

 1 <template>
2 <svg
3 class="NuxtLogo"
4 >
5 </svg>
6 </template>
7 <style>
8 .NuxtLogo {
9 margin: auto;
10 }
11 </style>

在 page/index.vue 文件中引入 `import Logo from '~/components/Logo.vue';` 会报错:`File 'xxx/components/Logo.vue' is not a module. Vetur(2306)`。

typescript 提示新增 vue-shims.d.ts ( https://github.com/Microsoft/TypeScript-Vue-Starter#single-file-components ),试过还是不行。

github issue 翻了一下,最后找到这个:https://github.com/vuejs/vetur/issues/1709

给 components/Logo.vue 添加 export 即可:

 1 <template>
2 <svg
3 class="NuxtLogo"
4 >
5 </svg>
6 </template>
7 <style>
8 .NuxtLogo {
9 margin: auto;
10 }
11 </style>
12 <script lang="ts">
13 import Vue from 'vue';
14
15 export default Vue.extend({
16 name: 'LOGO',
17 });
18 </script>

添加之后,还需关闭重启 VSCode !

nuxt.js 使用 Typescript 在 VSCode 报错: File 'xxx/components/Logo.vue' is not a module. Vetur(2306)的更多相关文章

  1. nuxt.js 初始化 npm run dev 报错

    在初始化 npm install 了基本依赖后: npm run dev 报错: error in ./server/index.js Module build failed: Error: Plug ...

  2. Angular5 import interface 报错:XXX is not a module

    在项目里定义了一个interface,device.ts.然后在component.ts中要使用这个interface,import之后,VSCode报错:‘xxx/xxx/xxx/device.ts ...

  3. vue使用v-for时vscode报错 Elements in iteration expect to have 'v-bind:key' directives

    vue使用v-for时vscode报错 Elements in iteration expect to have 'v-bind:key' directives Vue 2.2.0+的版本里,当在组件 ...

  4. vscode源代码管理(vscode报错 未找到Git,请安装Git,或在"git.path" 设置中配置)

    vscode源代码管理(vscode报错 未找到Git,请安装Git,或在"git.path" 设置中配置) 直接上图,电脑上已经安装git,由于vscode没有找到git,所以v ...

  5. Vscode报错: error:0308010C:digital envelope routines::unsupported错误记录解决

    Vscode报错: error:0308010C:digital envelope routines::unsupported错误记录解决 因为安装了新版本的node才报的错误:node版本: v18 ...

  6. centos7 安装nginx和php5.6.25遇到 无法访问php页面 报错file not found 问题解决

    php-fpm安装完成,nginx安装完成 netstap -ntl| 发下端口正常开启 iptables -L 返现9000端口已经开放 ps -aux|grep nginx 发下nginx进程正常 ...

  7. 树莓派(Raspberry Pi 3) centos7使用yum命令报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:

    使用yum命令报错 File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^SyntaxError: invalid ...

  8. yum命令报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:

    使用yum命令报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: 问题出现原因:yum包管理是使用python2 ...

  9. Egret项目Typescript的编译报错

    今天编译项目,出现了一个奇怪的报错,如下: E:\engine\egret-core-3.1.2\tools\lib\typescript\tsclark.js:41531 1> if (fil ...

  10. nuxt 运行项目后 中总是报错

    报错的内容: nuxt.config.js中的图片 如果出现第一张图的中的错误: 请注释掉第二张图中extend里面的loader:'eslit-loader',或者把extend里面if下面的内容全 ...

随机推荐

  1. betterZip解压后压缩包会删除 zip文件解压后原压缩文件能不能删掉

    https://www.betterzipcn.com/faq/better-ydeq.html 品牌型号:MacBook Book Air 系统:MacOS Mojave 10.14 软件版本:Be ...

  2. Qt控件SDK使用示例大全

    文章 链接 01表盘控件-01汽车仪表盘-gaugecar https://qtchina.blog.csdn.net/article/details/120240257 01表盘控件-02圆弧仪表盘 ...

  3. Qt编写安防视频监控系统19-日志查询

    一.前言 日志查询功能是基础功能,主要分两块,一个是本地日志查询,包括运行日志.报警日志.操作日志:一个是设备日志查询,就是通过SDK去拉去NVR设备的日志信息,包括系统操作.配置操作.报警操作.录像 ...

  4. Gitea搭建

    关闭注册 找到gitea的配置文件gitea/conf/app.ini,把下面的设置改为true即可: [service] DISABLE_REGISTRATION = true 关闭openid [ ...

  5. 解决pip命令报错及Python环境配置指南:从安装到优化

    1. 错误日志 当我在 Linux 机器(使用 Debian 或 Ubuntu 或衍生发行版)上运行 pip install xyz 时,会出现这样的错误: error: externally-man ...

  6. VisualSFM的配置与使用 & MeshLab的网格生成与纹理添加

    VisualSFM的配置与使用 & MeshLab的网格生成与纹理添加 翻译 搜索 复制

  7. 推荐一个windows系统的下载和安装的网址:win7之家

    win7之家:http://www.windows7en.com/ 精校 完整 极致 Windows系统下载仓储站HelloWindows :https://hellowindows.cn/

  8. Android保活从入门到放弃:乖乖引导用户加白名单吧(附7大机型加白示例)

    1.引言 IM在Android上的保活问题经常在即时通讯网的论坛和技术群里被讨论,自从Android 8.0后系统大大降低了后台运行应用的保活容忍度(详见<Android P正式版即将到来:后台 ...

  9. FreeSWITCH日志功能分析及apr模拟

    操作系统版本:Debian 12.5_x64 FreeSWITCH版本: 1.10.11 apr库版本:apr-1.7.4 & apr-util-1.6.3 gcc版本: 12.2.0   日 ...

  10. Solution -「CF 590E」Birthday

    \(\mathscr{Description}\)   Link.   给定 \(n\) 个字符串 \(S_{1..n}\),选出其一个最大子集 \(T\),使得 \(T\) 中的字符串两两不存在包含 ...