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. Redis 中 scan 命令踩坑

    原本以为自己对redis命令还蛮熟悉的,各种数据模型各种基于redis的骚操作.但是最近在使用redis的scan的命令式却踩了一个坑,顿时发觉自己原来对redis的游标理解的很有限.所以记录下这个踩 ...

  2. [转]为什么VS提示SurfFeatureDetector不是cv的成员函数

    surf和sift算法都是在头文件#include <opencv2/features2d/features2d.hpp>中,但在新的opencv版本出来后,如果仍然使用这个头文件就会出现 ...

  3. [转]使用navicat将excel文件导入mysql数据库

    excel: 注: 1.mysql里建立一张跟excel一样的表结构的表(包含id) 2.excel最好没有任何格式,只是纯值,不然会出现导入不了的错误 ----------------------- ...

  4. python基础学习4

    打开文件的方式 # 第一种 f = open('C:\project\pycharmprojects\\bigdata33\day05/cars.csv', mode='r', encoding='U ...

  5. org.junit.Assert

    引入包,以下两种方式都是OK的,看个人喜好,我倾向于使用第二种,会更加清晰直观.下面的代码我都会用第二种 import static org.junit.Assert.*; import org.ju ...

  6. Python使用技巧2

    python url网址拼接 在做爬虫中,经常会遇到需要把一个域名和网址路径进行拼接,在开发时一时没想到方法,特此记录下来. 利用parse.urljoin方法进行网址拼接 from urllib i ...

  7. SM9-密钥交换

    算法过程 代码实现 ///************************************************************************ // File name: ...

  8. 某次信创环境Oceanbase数据库偶发乱码问题

    资料迁移,整理分享. 问题发生在2023年 一.环境介绍及问题简述 数据库 oceanbase 操作系统 Linux (麒麟) WEB中间件 Tongweb 数据库表编码 GBK 中间件默认使用的HT ...

  9. ADC温敏电阻测温

    一.ADC采样电路 使用热敏电阻与连续逼近型寄存器 (SAR) 模数转换器 (ADC) 直接监测温度的电路.温度检测电路使用负温度系数 (NTC) 热敏电阻与电阻串联构成分压器. 参考电压:VCC 分 ...

  10. dart中Map类型详解

    Map是什么 map类型的数据都是由key和value两个值组成, key是唯一的,value不必唯一,读写数据都是通过key进行. key和value可以是任意类型数据. Map的基本使用 01== ...