【发布时间】:2020-11-07 10:22:12
【问题描述】:
我正在尝试使用 git hub 支持在 Amazon Web Services(AWS) 上部署 React.js Web 应用程序。它已部署,我得到了 url,但应用程序看起来与在本地运行时不同。
我已按照here 给出的步骤进行操作。
我使用了默认的构建配置设置并且没有改变任何东西。
下面是在本地运行时的样子。
下面是它在 AWS amplify 提供的链接上的样子。
谁能指出我应该做些什么不同的事情?我需要配置一些东西吗?我已经为前端组件使用了 material-ui 和 react-bootstrap。
App.js - 渲染函数
render() {
return (
<div className={classes.container}>
<AppBar
className={classes.navbar}
style={{ backgroundColor: "transparent" }}
position="static"
>
<Toolbar>
<IconButton
edge="start"
className={classes.menuButton}
color="inherit"
aria-label="menu"
>
<img alt="Logo" className={classes.logo} src={Logo} />
</IconButton>
<Typography variant="h6">TIP-TOP NX</Typography>
</Toolbar>
</AppBar>
<div className={classes.content}>
<div className={classes.frame}>
<Avatar style={{ margin: "auto", marginTop: "1em" }}>
<LockOutlined />
</Avatar>
<h3 style={{ color: "black", margin: "20px" }}>Sign in</h3>
<div
style={{
marginBottom: "3vh",
display: this.state.invalid ? "block" : "none",
}}
>
<Typography variant="h6" color="error">
Invalid details!
</Typography>
</div>
<TextField
fullWidth
required
label="Email"
variant="outlined"
error={this.state.errors.email.length > 0}
onChange={this.changeHandler("email")}
/>
<TextField
fullWidth
required
label="Password"
variant="outlined"
type="password"
error={this.state.errors.password.length > 0}
onChange={this.changeHandler("password")}
style={{ marginTop: "1em" }}
/>
<Button
onClick={this.submitHandler}
style={{ margin: "5vh auto" }}
variant="contained"
color="primary"
size="large"
>
Submit
</Button>
</div>
</div>
<footer className={classes.footer}>© 2020-2021</footer>
</div>
);
}
链接的css文件:
.container {
display: flex;
flex-direction: column;
min-height: 100vh;
background: #555; /* fallback for old browsers */
background: -webkit-linear-gradient(
to right,
#555,
#000
); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #555, #000);
}
.logo {
height: 5vh;
border-radius: 50%;
margin-right: 1vw;
}
.navbar {
background-color: transparent;
color: white;
border-bottom: 1px solid white;
}
.active {
color: black;
background-color: white;
padding: 0.5em 1em 0.5em 1em;
font-size: 1.2em;
box-sizing: border-box;
opacity: 80%;
}
.content {
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 90vh;
text-align: center;
box-sizing: border-box;
}
.frame {
background-color: #e0e0e0;
width: 30%;
height: auto;
opacity: 80%;
padding: 20px;
margin: 20px;
box-sizing: border-box;
border: 2px white solid;
color: black;
}
.footer {
color: white;
text-align: center;
border-top: 1px solid white;
height: 10vh;
display: flex;
align-items: center;
justify-content: center;
}
@media only screen and (max-width: 1000px) {
.frame {
width: 50%;
}
}
【问题讨论】:
-
您的路由定义是否正确?生产和开发路线可能有问题,所以部署的版本没有导航到 i.g.
domain/login其中你的应用导航到开发模式localhost/login -
除了上面的提示,一般来说,你的问题很模糊,把问题缩小到具体的问题,也包括一些相关的代码。
-
@Amir-Mousavi 抱歉,我是 AWS 新手,没有可包含的代码。这个页面是主页,所以它位于 localhost/ 而不是 localhost/login。登录框在背景后面可见,我可以输入。
标签: reactjs amazon-web-services