我是js新手
我试图将所有这些逻辑移到辅助函数中,而不是在render方法中
我面临语法错误。
你们能告诉我如何解决吗?
在下面提供我的代码。



  ./src/components/first-time-tab/player-setup.jsx
  
  模块构建失败:SyntaxError:C:/workspace/fasg-sports-dashboard/src/components/first-time-tab/player-setup.jsx:意外令牌(11:16)


   9 |     renderAccountTabContent() {
  10 |             return (
> 11 |                 let sportsStartDate = this.props.playerInfo.sportsStartDate;

最佳答案

在您的错误中,它表明您尝试return变量赋值,而不是代码。将此行放在收益表之外。

尝试这个 ...

renderAccountTabContent() {
        let sportsStartDate = this.props.playerInfo.sportsStartDate;
        let renderData;

        let now = moment().format('YYYY-MM-DD');
        let past1Days = moment().subtract(1, 'days').format('YYYY-MM-DD');
        let past2Days = moment().subtract(2, 'days').format('YYYY-MM-DD');
        let past3Days = moment().subtract(3, 'days').format('YYYY-MM-DD');

        if(sportsStartDate && sportsStartDate === now) {
            renderData = 'We’re setting up your player and verifying the funds you’ve deposited. Don’t worry — it might take a couple of days for your player to reflect your balance.';
        } else if(sportsStartDate && sportsStartDate === past1Days) {
            renderData = "We’re setting up your player and verifying the funds you’ve deposited. Don’t worry — it might take a couple of days for your player to reflect your balance.";
        } else if(sportsStartDate && sportsStartDate === past2Days) {
            renderData = "We’re making some progress. See what’s happening today.";
        } else if(sportsStartDate && sportsStartDate === past3Days) {
            renderData = "We’ve put your money to work in your investment player.See what’s happening today.";
        } else {
            renderData = "Your new portfolio is a work in progress. See what’s happening today.";
        }

        return (
            renderData
        );
}

关于javascript - 模块构建失败:SyntaxError:意外 token (11:16),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40730790/

10-11 05:36