

























vscode vue2项目 自定义 abc类型 自动提示 3种提示方式 分别是 abc this.abc window.abc
{
"compilerOptions": {
"allowJs": true, <-- 重点是这个 开启自动提示
"checkJs": true, <-- 重点是这个 开启自动提示
"baseUrl": "./",
"paths": {
"@/*": ["src/*"],
"./*": ["./*"]
}
},
"include": [
"src/**/*", <-- 重点是这个 这是是扫描 .d.ts 的目录范围 自动加载
"src/types/types.js"
],
"exclude": [ "node_modules", "dist" ]
}
abc文件名 随便起
/src/types/abc.d.tsinterface AbcType {
/** @remarks 备注信息 */ name11: string;
/** 也可以不加quan 然后是两行 */
name22: string;
}
// 这个是vue里面的 this.abc
declare module "vue/types/vue" {
interface Vue {
abc: AbcType;
}
}
// 这个是 abc
// 这个是 window.abc
declare global {
/** 这里是abc的注释 */
const abc: AbcType;
interface Window {
/** 这里是 window.abc 的注释 */
abc: AbcType;
};
}
export { }
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。