Vue — TS项目模拟
最后更新于:2022-04-02 08:11:38
>[success] # VueCli3.0 -- 配置
~~~
1.详情看Vue--模块化方式结构
~~~


>[danger] ##### 创建项目后一些文件配置
~~~
1.tslint.json -- 对ts检查风格的配置。
例如我们想让'tabs'等于两个空格可以配置'rules' 对象规则:"indent": [true, "tabs" , 2],
2.tsconfig.json -- ts一些检查配置,建议在'compilerOptions'
额外配置一个'"noImplicitAny": false'
3.如果使用'vscode' 编码建议在设置配置'autofxi' 查询中的'Edit in settings.json'中增加
"tslint.autoFixOnSave": true -- 保存时候做自动格式
~~~
[参考文章](https://www.w3cschool.cn/typescript/typescript-2.html)
~~~
1.非空断言 (解答为什么使用非空断言)
TypeScript现在有两个特殊的类型:Null和Undefined, 它们的值分别是null和undefined。 以前这是不可能明确地命名这些类型的,但是现在 null和undefined不管在什么类型检查模式下都可以作为类型名称使用。
以前类型检查器认为null和undefined赋值给一切。实际上,null和undefined是每一个类型的有效值, 并且不能明确排除它们(因此不可能检测到错误)。
2.所有的都是null和undefined 子集因此,及时你标注了'string' 类型由于,undefined
也属于string 所以也可以赋值'undefined' ,但不是我们实际想要的
@Prop({ default: 'default value' }) readonly propB!: string
~~~
';