Vue + TypeScript 重构 vue-admin-element 小结
栏目: JavaScript · 发布时间: 7年前
内容简介:简单看了下
简单看了下 typescript 官网 的语法,就想借助一个项目实战下。这里选用了 vue-admin-element
附上源码地址: vue-element-admin-ts ,欢迎 star 或 fork
遇到的问题及解决方案
-
Q: error TS7017: Index signature of object type implicitly has an 'any' type
A: https://stackoverflow.com/que...
或者在
tsconfig.json文件的compilerOptions选项中添加"noImplicitAny": false
-
Q: error TS2339: Property 'webkitURL' does not exist on type 'Window'
A: https://stackoverflow.com/que...
interface Window { webkitURL?: any; } declare var window: Window; -
Q: Property 'context' does not exist on type 'NodeRequire'.
A: https://github.com/rails/webp...
npm i -D @types/webpack-env
- Q: 'this' implicitly has type 'any' because it does not have a type annotation
-
Q: 导入 .vue 时,为什么会报错,即使所写的路径并没有问题?
A: 在 TypeScript 中,它仅识别 js/ts/jsx/tsx 文件,为了让它识别 .vue 文件,我们需要显式告诉 TypeScript,vue 文件存在,并且指定导出 VueConstructor:
declare module '*.vue' { import Vue from 'vue' export default Vue } -
Q: TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
A: 空的数组添加数据的时候,会有这个提示,解决方案: https://github.com/Microsoft/...
-
Q: Property 'basePath' has no initializer and is not definitely assigned in the constructor.
59 | @Prop({required: true, default: {}}) public item: Route; 60 | @Prop({default: false}) public isNest: boolean; > 61 | @Prop({default: ''}) public basePath: string; - A: https://github.com/kaorun343/...
- Q: Object is possibly 'undefined'.
-
Q: Property '$refs' does not exist on type 'Element | Element[] | Vue | Vue[]'. Property '$refs' does not exist on type 'Element'.
A: https://github.com/vuejs/vue-...
以上所述就是小编给大家介绍的《Vue + TypeScript 重构 vue-admin-element 小结》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Web开发秘方
Brian P. Hogan、Chris Warren、Mike Weber、Chris Johnson、Aaron Godin / 七印部落 / 华中科技大学出版社 / 2013-7-10 / 66.00元
猜猜硅谷的前端工程师怎么折腾JS的?想知道无限下拉的列表怎么做吗?你知道DropBox可以当Web服务器用吗?你知道怎么做出跨平台的幻灯片效果吗?不借助插件,怎样在移动设备上实现动画效果?怎样快速搭建和测试HTML电子邮箱?怎样制作跨PC和移动设备显示的应用界面?怎样利用最新的JavaScript框架(Backbone和Knockout)提高应用的响应速度?怎样有效利用CoffeeScript和S......一起来看看 《Web开发秘方》 这本书的介绍吧!