? npm audit
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
Run Code Online (Sandbox Code Playgroud)
我运行 npm audit 并收到此错误。
当我在下面运行时:
? npm config get package-lock
true
? npm config get shrinkwrap
true
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?至于如何解决?并且 npm audit fix --force 也无法正常工作...
class App {
constructor() {
this.canvas = document.createElement('canvas');
document.body.appendChild(this.canvas);
this.ctx = this.canvas.getContext('2d');
this.pixelRatio = window.devicePixelRatio > 1 ? 2 : 1;
window.addEventListener('resize', this.resize.bind(this), false);
this.resize();
window.requestAnimationFrame(this.animate);
}
resize() {
this.stageWidth = document.body.clientWidth;
this.stageHeight = document.body.clientHeight;
}
animate = () => {
this.test(); // ---> here!
};
test = () => {
console.log('here!');
};
}
window.onload = () => {
new App();
};Run Code Online (Sandbox Code Playgroud)
箭头函数不会被提升,只有常规函数会被提升。为什么animate函数内部可以调用this.test?类中箭头函数的不同行为?