2016-07-26 170 views
0

我想做一個簡單的函數,將用戶重定向到主頁,如名稱所示。我無法擺脫這個錯誤:我如何設置一個eslint規則爲no-undefined?

*ReferenceError: location is not defined

有人可以幫助我,使用eslint?

export function goToHomePage() { 
    location = '/'; 
} 

我使用Backbone.js的MVC

+2

嘗試'window.location'繞過它 – alex

+0

導致:的ReferenceError:窗口沒有定義的。 :( –

+0

你有''env「:{」browser「:true}'? –

回答

0

試試你的ESLINT配置設置爲:

var esLintDevConfig = { 
    env: { 
     "browser": true, 
     "node": true, 
     "jquery": true 
    }, 
    "globals": { 
     "angular": true, "window": true, //anyother global variables 
    }, 
    rules: { 

    } 
};