这是我的服务等级:
let md5 = require('md5');
export default class RandomEmails {
randomEmails = [];
constructor(){
this.generateRandomEmails();
}
generateRandomEmails():void {
const chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
for(let i=0;i<=60;i++){
console.log('i'+i);
}
}
}
从我的index.ts像这样调用:
import "./index-style.css";
import RandomEmails from './components/random-email-service';
export class Hero {
id: number;
name: string;
constructor(name:string) {
this.name = name;
new RandomEmails(); //calling here;
}
myName()
{
return this.name;
}
}
let hero = new Hero('Arif-00');
console.log(hero.myName());
得到一个错误:
ERROR in ./src/index.ts
Module not found: Error: Can't resolve './components/random-email-service' in 'F:\JS-APP\src'
@ ./src/index.ts 4:31-75
问题是什么?如何导入类并调用它?有人帮我吗? Unitl类未调用,可以正常工作