【问题标题】:Lint error - unexpected string concatenationLint 错误 - 意外的字符串连接
【发布时间】:2019-04-12 19:28:32
【问题描述】:
render() {
    const { a, b } = this.props;
    if (// some condition // )
    window.location.assign('/v2#/org/' + a + '/support')}
}

对于 window.location.assign('/v2#/org/' + orgId + '/support')} 行,我收到 lint 错误 - 意外的字符串连接。

如何防止这种情况发生?

【问题讨论】:

标签: javascript reactjs lint


【解决方案1】:

改用字符串插值:

render() {
    const { a, b } = this.props;
    if (// some condition // )
    window.location.assign(`/v2#/org/${a}/support`)}
}

【讨论】:

    【解决方案2】:

    您应该使用由“`”(反勾号/重音符号)包裹的模板字符串。

    window.location.assign(`/v2#/org/${orgId}/support`)
    

    【讨论】:

      猜你喜欢
      • 2018-06-21
      • 1970-01-01
      • 1970-01-01
      • 2022-10-25
      • 2023-03-26
      • 1970-01-01
      • 2019-08-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多