当前位置:网站首页>对非ts/js文件模块进行类型扩充
对非ts/js文件模块进行类型扩充
2022-07-03 00:54:00 【程序猿向前跑】
对非ts/js文件模块进行类型扩充
ts只支持模块的导入导出, 但是有些时候你可能需要引入css/html等文件, 这时候就需要用通配符让ts把他们当做模块, 下面是对".vue"文件的导入支持(来自vue官方):
找不到 .vue 的声明文件,实际上就是 TS 无法识别 .vue 类型的文件。
引入.vue文件提示“Could not find a declaration file for module ‘xxx.vue’…”
有时候在开发过程中只是提示有错,不影响项目运行,但在打包时会报错,导致无法打包。
在src文件目录下(也就是你开发代码所在的文件夹)添加 shims-vue.d.ts 文件,内容为
// global.d.ts
declare module '*.vue' {
import {
DefineComponent } from 'vue'
const component: DefineComponent<{
}, {
}, any>
export default component
}
边栏推荐
- Lu Zhe, chief scientist of Shiping information: building data and personnel centered security capabilities
- 强化学习 Q-learning 实例详解
- MySQL
- 这不平凡的两年,感谢我们一直在一起!
- Database SQL language 02 connection query
- 1038 Recover the Smallest Number
- 【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
- Excel if formula determines whether the two columns are the same
- Win10 can't be installed in many ways Problems with NET3.5
- [自我管理]时间、精力与习惯管理
猜你喜欢

First hand evaluation of Reza electronics rz/g2l development board

Assets, vulnerabilities, threats and events of the four elements of safe operation

matlab 多普勒效应产生振动信号和处理
![[AUTOSAR twelve mode management]](/img/42/292e3da3f5d488a1e8c10ea9bbfbab.png)
[AUTOSAR twelve mode management]
![[case sharing] let the development of education in the new era advance with](/img/11/af88d16dc66f00840cbfc5ba5d68bd.jpg)
[case sharing] let the development of education in the new era advance with "number"

leetcode:701. 二叉搜索树中的插入操作【bst的插入】

全志A40i/T3如何通过SPI转CAN

Basic concept and implementation of overcoming hash

Merge K sorted linked lists
![[flutter] icons component (load the built-in icon of flutter | display the material design icon completely)](/img/f5/3ec22f1480227f33a1c8ac457155ed.jpg)
[flutter] icons component (load the built-in icon of flutter | display the material design icon completely)
随机推荐
安全运营四要素之资产、脆弱性、威胁和事件
按键精灵打怪学习-自动寻路回打怪点
全志A40i/T3如何通过SPI转CAN
Find a benchmark comrade in arms | a million level real-time data platform, which can be used for free for life
基本远程连接工具Xshell
Excel if formula determines whether the two columns are the same
异步、郵件、定時三大任務
数据分析思维分析犯法和业务知识——分析方法(一)
寻找标杆战友 | 百万级实时数据平台,终身免费使用
电话网络问题
Correctly distinguish the similarities and differences among API, rest API, restful API and web service
[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)
Telephone network problems
删除有序链表中重复的元素-II
Daily topic: movement of haystack
信息熵的基础
Reading and writing speed of Reza rz/g2l arm development board storage and network measurement
18_微信小程序之微信视频号滚动自动播放视频效果实现2.0
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
Database SQL language 02 connection query