2016-06-21 93 views
0

我有我的VUE對象這個方法:在資產ExecJS意外標記:運算符(>)在vue.js方法

fetchStates: function() { 
    this.$http.get('/api/locations/all_states').then((response) => { 
     states = $.parseJSON(response.responseText).states 
     this.$set('states', states) 
    }).then(() => { 
     $('.cs-select').trigger('chosen:updated') 
    }) 
    }, 

預編譯我得到這個錯誤:

ExecJS::ProgramError: Unexpected token: operator (>) (line: 62960, col: 69, pos: 1897152) 

我管理找到它來自哪裏,.then((response) => {,但不知道如何解決這個問題。可能是ExecJS不知道vue-resource中的promises語法。任何幫助表示讚賞。

回答

4

那麼,對於那些誰就會有同樣的問題,這是被我的問題是,它應該是.then(function(response) {代替.then((response) => {

fetchStates: function() { 
    this.$http.get('/api/locations/all_states').then(function(response) { 
     states = $.parseJSON(response.responseText).states 
     paymentInfo.$set('states', states) 
    }).then(function() { 
     $('.cs-select').trigger('chosen:updated') 
    }) 
    }, 
+1

這很有趣,我也有過類似的問題,其中,與'=>'語法相同的代碼在桌面和Android上工作,但在iOS中不起作用。所以我調試它在iOS上,我得到了像你一樣的異常 - 「意外的令牌:操作符(>)」。我不確定,但我認爲'=>'是一個js6標準,可能它還沒有完全支持。如果你知道更多關於這個我很樂意聽到的信息。同時,您的解決方案也適用於我+1。 –

+0

@ItaiSpector「我認爲'=>'是一個js6」這正是它的意思,我從博客文章中看到了這個,後來發現它使用了js6語法。 – rmagnum2002

+0

感謝您的回覆,我很感興趣知道它是否與支持問題有關,知道js6得到廣泛支持或不支持,以及何時可以得到全面支持仍然很有趣。這可能是在網絡上,只需要做一點谷歌搜索,照顧 –