Javascript 如何从节点模块的函数开头删除包名
因此,我有一个节点模块,但我想知道如果函数不使用Javascript 如何从节点模块的函数开头删除包名,javascript,node.js,node-modules,Javascript,Node.js,Node Modules,因此,我有一个节点模块,但我想知道如果函数不使用this,如何将somethingElse()转换为somethingElse(): const somethingElse = something.somethingElse; or const { somethingElse } = require('something'); or import { somethingElse } from 'something'; 如果它确实需要此,则需要使用绑定,以便此设置正确: const some
this
,如何将somethingElse()
转换为somethingElse()
:
const somethingElse = something.somethingElse;
or
const { somethingElse } = require('something');
or
import { somethingElse } from 'something';
如果它确实需要此
,则需要使用绑定
,以便此
设置正确:
const somethingElse = something.somethingElse.bind(something);
有趣的是,你可能不知道它是否需要
这个
,除非你尝试了它,它抛出了一个错误 如果函数不使用此:
const somethingElse = something.somethingElse;
or
const { somethingElse } = require('something');
or
import { somethingElse } from 'something';
如果它确实需要此
,则需要使用绑定
,以便此
设置正确:
const somethingElse = something.somethingElse.bind(something);
有趣的是,你可能不知道它是否需要这个
,除非你尝试了它,它抛出了一个错误