gpt4 book ai didi

javascript - Uncaught Error : Cannot find module "../../helpers/oidcHelpers.jsx"

转载 作者:行者123 更新时间:2023-12-03 06:40:52 25 4
gpt4 key购买 nike

我正在尝试导入模块,但它不断在浏览器(Chrome 和 Mozilla)控制台中抛出错误

未捕获错误:找不到模块“../../helpers/oidcHelpers.jsx” -- LoginController.jsx?1471:6

这是我的 LoginController.jsx 文件

import React, {Component, PropTypes} from 'react';

import ActionAndroid from 'material-ui/svg-icons/action/android';
import RaisedButton from 'material-ui/RaisedButton';

import userManager from '../../helpers/oidcHelpers.jsx';

export default class LoginController extends Component {
onFASLoginButtonClick = (event) => {
event.preventDefault();
console.log(userManager.signinRedirect);
userManager.signinRedirect();
};

render() {
return (
<div>
<RaisedButton
label="Login with FAS"
icon={<ActionAndroid/>}
onMouseUp={this.onFASLoginButtonClick}
/>
</div>
);
}
}

这是我的应用程序的目录结构。我已经剪掉了不需要的文件

app
├── actions
│   └── actions.jsx
├── containers
│   ├── login
│   │   └── LoginController.jsx
├── helpers
│   ├── oidcHelpers.jsx
│   └── oidcHelpers.jsx.sample
├── index.jsx
├── reducers
│   ├── authentication.jsx
│   └── index.jsx
├── routes.jsx
└── stylesheets
├── base
│   └── common.less
├── components
└── drawer.less

尝试了很多,但无法真正找出问题所在。我什至尝试删除导入语句并将导入更改为 import userManager from '../../helpers/oidcHelpers' 但我仍然不断收到相同的错误。进行更改不会更新浏览器中的代码。

代码托管在 Github 上:https://github.com/waartaa/waartaa/tree/develop/waartaa/client

最佳答案

您在 helpers/oidcHelpers.jsx 中没有默认导出 .

更改导入LoginController.jsx来自import userManagerimport { signinRedirect }并通过调用 signinRedirect 正确使用它不是userManager.signinRedirect

import React, {Component, PropTypes} from 'react';

import ActionAndroid from 'material-ui/svg-icons/action/android';
import RaisedButton from 'material-ui/RaisedButton';

import { signinRedirect } from '../../helpers/oidcHelpers.jsx';

export default class LoginController extends Component {
onFASLoginButtonClick = (event) => {
event.preventDefault();
console.log(signinRedirect);
signinRedirect();
};

render() {
return (
<div>
<RaisedButton
label="Login with FAS"
icon={<ActionAndroid/>}
onMouseUp={this.onFASLoginButtonClick}
/>
</div>
);
}
}

关于javascript - Uncaught Error : Cannot find module "../../helpers/oidcHelpers.jsx",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37967475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com