0

我正在学习 React.js。我正在开发一个应用程序。我的代码如下

<div className="ui pagination menu">
            <span
              className={
                this.props.page === 1
                  ? 'disabled item pagination'
                  : 'item pagination'
              }
              onClick={() => {
                if (this.props.page === 1) {
                  return false;
                }
                this.pagination(this.props.page - 1);
              }}
            >
              ❮
            </span>
            <div className="item">
              Page {this.props.page} of {this.props.maxPages}
            </div>
            <span
              className={
                this.props.page === this.props.maxPages
                  ? 'disabled item pagination'
                  : 'item pagination'
              }
              onClick={() => {
                if (this.props.page === this.props.maxPages) {
                  return false;
                }
                this.pagination(this.props.page+1); 

                <h1 className="ui attached warning message table">  // Line 185
                  <span id="address">Addresses</span>
                  <span id="user_details">
                    Welcome,  <b> { this.state.userName } </b>  |
                    <span id="logout" onClick={this.logout}> Logout </span>
                    <button className="ui teal button" onClick={this.openPopup}> <i className="plus square icon" />
                      Add Address
                    </button>
                  </span>
                </h1>
              {this.props.addresses.length > 0 ? (

我越来越Warning像下面

Line 185:  Expected an assignment or function call and instead saw an expression  no-unused-expressions

谁能说我该如何解决Warning

4

2 回答 2

2

I think you have missed closing of onClick function before your line 185, you should do this,

<span
  className={
      this.props.page === this.props.maxPages
      ? 'disabled item pagination'
      : 'item pagination'
  }
  onClick={() => {
    if (this.props.page === this.props.maxPages) {
        return false;
    }
    this.pagination(this.props.page+1); 
}} //This is missing
> //closing of span is also missing
<h1 className="ui attached warning message table">  // line 185
于 2019-07-11T02:49:55.507 回答
0

我相信您错过了 onClick 的结束声明。使用 IDE 和安装 prettier 可能会有所帮助。这将帮助您查看缺少语法的地方。此外,以下是有关错误原因的更多信息:

http://linterrors.com/js/expected-an-assignment-or-function-call

于 2019-07-11T02:59:52.813 回答