nuxt.js 使用 Typescript 在 VSCode 报错: File 'xxx/components/Logo.vue' is not a module. Vetur(2306)
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)的更多相关文章
- nuxt.js 初始化 npm run dev 报错
在初始化 npm install 了基本依赖后: npm run dev 报错: error in ./server/index.js Module build failed: Error: Plug ...
- Angular5 import interface 报错:XXX is not a module
在项目里定义了一个interface,device.ts.然后在component.ts中要使用这个interface,import之后,VSCode报错:‘xxx/xxx/xxx/device.ts ...
- 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+的版本里,当在组件 ...
- vscode源代码管理(vscode报错 未找到Git,请安装Git,或在"git.path" 设置中配置)
vscode源代码管理(vscode报错 未找到Git,请安装Git,或在"git.path" 设置中配置) 直接上图,电脑上已经安装git,由于vscode没有找到git,所以v ...
- Vscode报错: error:0308010C:digital envelope routines::unsupported错误记录解决
Vscode报错: error:0308010C:digital envelope routines::unsupported错误记录解决 因为安装了新版本的node才报的错误:node版本: v18 ...
- centos7 安装nginx和php5.6.25遇到 无法访问php页面 报错file not found 问题解决
php-fpm安装完成,nginx安装完成 netstap -ntl| 发下端口正常开启 iptables -L 返现9000端口已经开放 ps -aux|grep nginx 发下nginx进程正常 ...
- 树莓派(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 ...
- yum命令报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:
使用yum命令报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: 问题出现原因:yum包管理是使用python2 ...
- Egret项目Typescript的编译报错
今天编译项目,出现了一个奇怪的报错,如下: E:\engine\egret-core-3.1.2\tools\lib\typescript\tsclark.js:41531 1> if (fil ...
- nuxt 运行项目后 中总是报错
报错的内容: nuxt.config.js中的图片 如果出现第一张图的中的错误: 请注释掉第二张图中extend里面的loader:'eslit-loader',或者把extend里面if下面的内容全 ...
随机推荐
- Qt编写视频监控系统72-通过onvif增删改查OSD
一.前言 之前监控系统中原创的onvif协议解析机制,已经能够满足绝大部分用户的需要,比如搜索设备.获取视频流地址并播放.云台控制.预置位管理.图片亮度色彩饱和度等参数设置等,近期又多了一个需求,那就 ...
- [转]idea2021.1破解版 附安装教程免激活码
参看链接:http://www.ddooo.com/softdown/190256.htm 百度网盘地址:https://pan.baidu.com/share/init?surl=qwywmPK-F ...
- 阿里云maven仓库地址的配置
两种配置方式: 1. maven 配置文件配置settings.xml中设置mirror节点 <mirror> <id>nexus-aliyun</id> < ...
- 【OpenGL ES】GLSL基础语法
1 前言 本文将介绍 GLSL 中数据类型.数组.结构体.宏.运算符.向量运算.矩阵运算.函数.流程控制.精度限定符.变量限定符(in.out.inout).函数参数限定符等内容,另外提供了一个 ...
- macos(m1)编译测试深度学习推理框架
mnn build tnn
- Bogus:.NET的假数据生成利器
我们在项目开发中,为了保证系统功能完整.准确性,我们都需要模拟真实数据进行测试. 今天推荐一个开源库,方便我们制造假数据测试. 01 项目简介 Bogus 是一个开源的 .NET 库,它提供了一个强大 ...
- 前端学习openLayers配合vue3(加载线上数据源)
现在我们学习一下加载网上的线上数据再加上点矢量图层,紧接着上一步 关键代码 layers: [ //瓦片图层source第三方,或者自带的,地图的底层 new TileLayer({ // sourc ...
- Mac terminal proxy
cat >> ~/.bash_profile << EOF function proxy_on() { export http_proxy=http://127.0.0.1:7 ...
- Storm基本概念
storm简介 场景 伴随着信息科技日新月异的发展,信息呈现出爆发式的膨胀,人们获取信息的途径也更加多样.更加便捷,同时对于信息的时效性要求也越来越高.举个搜索场景中的例子,当一个卖家发布了一条宝 ...
- Qml 中实现任意角为圆角的矩形
[写在前面] 在 Qml 中,矩形(Rectangle)是最常用的元素之一. 然而,标准的矩形元素仅允许设置统一的圆角半径. 在实际开发中,我们经常需要更灵活的圆角设置,例如只对某些角进行圆角处理,或 ...