Lint错误 - 意外的字符串连接

问题描述 投票:1回答:2
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
2个回答
1
投票

你应该使用由“`”包裹的模板字符串(后面的刻度/重音符号)。

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

4
投票

使用字符串插值代替:

render() {
    const { a, b } = this.props;
    if (// some condition // )
    window.location.assign(`/v2#/org/${a}/support`)}
}
© www.soinside.com 2019 - 2024. All rights reserved.