我有一个api-service.jsx,它声明并导出HttpService类,然后将其导入特定的服务中,如下所示:
api-service.jsx:
class HttpService {
get(endpoint) {...};
post(endpoint) {...};
}
export default HttpService;
user-service.jsx:
import HttpService from './api-service';
export const userService = {
signin,
signup
};
const http = new HttpService();
function signin(email, password, context) {
return http.post('/users/signin', {email, password}, context);
}
function signup(data, that, context) {
return http.post('/users/signup', data, context);
}
例如主页
import {userService} from "./user-service";
到目前为止,此结构一直有效。现在,我包含了另一个名为localization.jsx的服务,该服务的结构与user-service.jsx相同,但是,当我尝试在任何地方包括以下位置的本地化服务时:
import {localizationService} from "./localization-service";
我收到以下错误:
TypeError:_api_service__WEBPACK_IMPORTED_MODULE_0__。默认不是构造函数
19 | };
20 |
21 | console.log(HttpService);
> 22 | const http = new HttpService();
23 |
24 | function signin(email, password, context) {