Categories
Vue Answers

How to fix window is not defined in Vue.js?

Spread the love

Sometimes, we want to fix window is not defined in Vue.js.

In this article, we’ll look at how to fix window is not defined in Vue.js.

How to fix window is not defined in Vue.js?

To fix window is not defined in Vue.js, we should add the browser property and set it to true in the ESLint config.

For instance, we write

module.exports = {
  //...
  env: {
    browser: true,
    node: true,
  },
  //...
};

to add the env.browser property and set it to true so ESLint will stop throwing the window is not defined error.

Conclusion

To fix window is not defined in Vue.js, we should add the browser property and set it to true in the ESLint config.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *