【发布时间】:2020-03-06 22:52:58
【问题描述】:
我正在写一个 vue 记录器插件
export default new (class NestLogger {
public install(Vue: any) {
Vue.prototype.$log = this;
}
error(text: string) {
console.log(text)
}
})();
在 main.ts 中
import logger from "./plugins/logger";
Vue.use(logger);
但在组件中我无法引用 this.$log - 为什么?
在 Login.vue 中
this.$log.error("bla");
错误:Property $log does not exist on type Login
【问题讨论】:
标签: typescript vue.js