admin 管理员组

文章数量: 1086019

I am using snackbar in Material-UI, and I encountered Error: Material-UI: capitalize(string) expects a string argument.

My code

    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"
            />

I think the problem is in the anchorOrigin field, because it worked when I mented that 2 lines out though I couldn't specify the location of the snackbar that way.

And as I mented above, neither of the 2 approaches works.

Snackbar document: /

Could anyone point out where I did wrong?

Thanks in advance!

I am using snackbar in Material-UI, and I encountered Error: Material-UI: capitalize(string) expects a string argument.

My code

    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"
            />

I think the problem is in the anchorOrigin field, because it worked when I mented that 2 lines out though I couldn't specify the location of the snackbar that way.

And as I mented above, neither of the 2 approaches works.

Snackbar document: https://material-ui./ponents/snackbars/

Could anyone point out where I did wrong?

Thanks in advance!

Share Improve this question asked Jul 18, 2020 at 17:15 SnookumsSnookums 1,3405 gold badges25 silver badges54 bronze badges 1
  • I think you have added like this anchorOrigin={{"bottom", "right"}} – Jay Parmar Commented Jul 18, 2020 at 17:20
Add a ment  | 

1 Answer 1

Reset to default 6

From the docs, anchorOrigin takes an object like this:

anchorOrigin={{
  vertical: 'bottom',
  horizontal: 'left',
}}

You are omitting the inner {} and vertical and horizontal property names in your implementations

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)