pow*_*eed 2 javascript reactjs material-ui
我在 Material-UI 中使用 Snackbar,并且遇到了Error: Material-UI: capitalize(string) expects a string argument.
我的代码
this.state = {
snackBarOpenVertical: "bottom",
snackBarOpenHorizontal: "right",
};
<Snackbar
// Neither of the 2 following approaches works.
anchorOrigin={"bottom", "right"}
anchorOrigin={this.state.snackBarOpenVertical, this.state.snackBarOpenHorizontal}
open={true}
onClose={this.handleSnackBarClose}
message="I love snacks"
/>
Run Code Online (Sandbox Code Playgroud)
我认为问题出在现场anchorOrigin,因为当我评论出 2 行时它就起作用了,尽管我无法以这种方式指定小吃店的位置。
正如我上面评论的,这两种方法都不起作用。
Snackbar 文档: https: //material-ui.com/components/snackbars/
谁能指出我哪里做错了?
提前致谢!
从文档中,anchorOrigin采用这样的对象:
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
Run Code Online (Sandbox Code Playgroud)
您在实现中省略了内部名称{}和属性vertical名称horizontal
| 归档时间: |
|
| 查看次数: |
10369 次 |
| 最近记录: |