在以以下方式实例化模块方法时,是否有一种方法可以使VS代码智能感知工作:
lib.js :
export function foo() {
this.aMethod = function() {
console.log('bar');
}
}main.js :
import { foo } from "./lib.js";
function bar() {
this.newFoo = new foo();
this.newFoo. <-- no intellisense here, "aMethod" is not suggested...
}我做错什么了吗?
发布于 2017-11-28 08:35:31
定义类的正确方法是
export function foo() {
this.aMethod = function() {
console.log('bar');
}
}或
export function foo() {
}
foo.prototype.aMethod = function() {
console.log('bar');
}之后,VSCode应该能够检测到对象的方法
https://stackoverflow.com/questions/47526969
复制相似问题