How to fix ‘Vue is not defined’ with Vue.js?

Sometimes, we want to fix ‘Vue is not defined’ with Vue.js.

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

How to fix ‘Vue is not defined’ with Vue.js?

To fix ‘Vue is not defined’ with Vue.js, we add the Vue script before we create Vue instance.

For instance, we write

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>

Then we write

<script>
  const demo = new Vue({
    el: "#app",
    data: {
      message: "Hello!",
    },
  });
</script>

to create a Vue instance after the Vue script tag.

Conclusion

To fix ‘Vue is not defined’ with Vue.js, we add the Vue script before we create Vue instance.