【问题标题】:Adding loading state on button - Reactjs Shopify Polaris在按钮上添加加载状态 - Reactjs Shopify Polaris
【发布时间】:2017-09-14 06:52:15
【问题描述】:

当用户单击 login 时,我正在尝试在按钮上添加加载状态,直到登录功能返回某些内容。

简单的按钮是这样的:

<Button primary onClick={this.handleSubmit}></Button>

加载按钮是这样的:

<Button primary onClick={this.handleSubmit} Loading></Button>

所以我想在用户单击按钮时将Loading 属性添加到按钮中,但我在以下代码中出现错误:

这里是按钮代码:

<Button primary onClick={this.handleSubmit} {this.state.buttonloading}>Login</Button>

错误:

Syntax error: Unexpected token, expected ... (64:61)
AT: <Button primary onClick={this.handleSubmit} {this.state.buttonloading}>Login</Button>
                                                ^

我想如何在 Button 组件中添加 Loading 属性

PS。我正在使用Shopify Polaris Components

【问题讨论】:

    标签: javascript jquery reactjs shopify polaris


    【解决方案1】:

    改成

    <Button primary onClick={this.handleSubmit} Loading={this.state.buttonloading}>Login</Button>
    

    【讨论】:

    • 非常感谢 :)
    • @Giang Le,你能补充解释吗,它将确保这个答案是完整的:)
    • “加载”被称为“道具”。在“Button”组件中,它调用“this.props.Loading”,如果为true,则在组件按钮中设置Loading。他们使用简短的语法“Loading”而不是 Loading={true}。对不起我的英语不好
    猜你喜欢
    • 1970-01-01
    • 2011-11-05
    • 1970-01-01
    • 1970-01-01
    • 2013-03-08
    • 2016-12-05
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    相关资源
    最近更新 更多