我安装了2个NPM包,它们都有一个随机();函数 如何指定从哪个NPM包调用随机方法
以下是我的代码:
import { random } from 'superheroes';
import { random } from 'supervillains';
console.log(random());
console.log(random());
我安装了2个NPM包,它们都有一个随机();函数 如何指定从哪个NPM包调用随机方法
以下是我的代码:
import { random } from 'superheroes';
import { random } from 'supervillains';
console.log(random());
console.log(random());
你可以用import alias
import { random as randomSuperheroes } from 'superheroes';
import { random as randomSupervillains } from 'supervillains';
// You can call it using the alias name
console.log(randomSuperheroes()); // superheroes
console.log(randomSupervillains()); // supervillains