【问题标题】:meteor - unexpected token error when using arrow notation流星 - 使用箭头符号时出现意外的令牌错误
【发布时间】:2016-05-23 05:28:11
【问题描述】:

我正在实现一些路由组,基于使用箭头符号的post I found

我正在使用最新版本的流星,所有顶级依赖项也是最新的。

当我保存我的 routes.js 时,我收到一个意外的令牌错误,该错误在代码中的箭头符号上失败。我肯定遗漏了一些明显的东西,有什么线索吗?

loggedIn = FlowRouter.group
  triggersEnter: [ ->
    unless Meteor.loggingIn() or Meteor.userId()
      route = FlowRouter.current()
      unless route.route.name is 'login'
        Session.set 'redirectAfterLogin', route.path
      FlowRouter.go ‘loginLayout’
  ]

错误:

在为 web.browser 构建时: 导入/启动/客户端/routes.js:10:18:意外令牌 (10:18)

【问题讨论】:

    标签: javascript meteor flow-router


    【解决方案1】:

    本教程使用的是 coffeescript 而不是 js,您将它加载到一个应该是 .coffee 的 .js 文件中,但是如果您在 routes.js 中有其他 js 代码,那么您需要将 coffee 转换为 js。上面的 sn-p 会变成:

    var loggedIn = FlowRouter.group({ 
        triggersEnter: [ function() { 
            var route; 
            if (!(Meteor.loggingIn() || Meteor.userId())) { 
                route = FlowRouter.current(); 
                if (route.route.name !== 'login') { 
                    Session.set('redirectAfterLogin', route.path); 
                } 
                return FlowRouter.go(‘loginLayout’); 
            } 
        }] 
    });
    

    【讨论】:

    • 不敢相信我没有发现它是咖啡脚本。这是漫长的一天哈哈。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-06
    • 1970-01-01
    • 2018-06-23
    • 2018-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多