模块构建失败:SyntaxError:意外的令牌(11:16)

时间:2016-11-21 22:46:04

标签: javascript jquery html reactjs redux

  • 我是js的新手
  • 我试图在辅助函数中而不是在渲染方法中移动所有这些逻辑
  • 我遇到语法错误。
  • 你能告诉我如何解决它。
  • 在下面提供我的代码。
  

./ SRC /组件/首次标签机/播放机-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;

1 个答案:

答案 0 :(得分:1)

在您的错误中,它显示您尝试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
        );
}