Weird "Vue is not defined" error ...
See original GitHub issueHi,
I am registering the component as per the docs and importing Vue as per my other components but getting the error "Error in created hook: “ReferenceError: Vue is not defined”.
Below is the complete .vue file.
Any help greatly appreciated.
Thanks.
<template>
<div>
<datatable :columns="columns" :data="rows"></datatable>
</div>
</template>
<script>
import Vue from "vue"
import DatatableFactory from "vuejs-datatable"
Vue.use(DatatableFactory)
export default {
data () {
return {
columns: [
{label: "id", field: "id"},
{label: "Username", field: "user.username"},
{label: "First Name", field: "user.first_name"},
{label: "Last Name", field: "user.last_name"},
{label: "Email", field: "user.email"},
{label: "address",
representedAs: function (row) {
return row.address + "<br />" + row.city + ", " + row.state
},
interpolate: true
}
],
rows: [
{
"id": 1,
"user": {
"username": "dprice0",
"first_name": "Daniel",
"last_name": "Price",
"email": "dprice0@blogs.com"
},
"address": "3 Toban Park",
"city": "Pocatello",
"state": "Idaho"
}
]
}
}
}
</script>
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Vue is not defined - javascript - Stack Overflow
I am trying to build a demo app with Vue.js. What I am getting is an odd error that ...
Read more >Vue is not defined! $ is not defined! What am i doing wrong?
Chrome is giving an error Vue is not defined . I tried to use ellixir browserify with jquery just to test it out,...
Read more >ReferenceError is not defined errors in production but works in ...
I made my first vue3 app, it is working in development but not in production (vite build). I've managed to re…
Read more >3 Anti-Patterns to avoid in Vue.js - Binarcode
The shortest code is not always the best and "easy and fast" ways can often have disadvantages. Every programming language, project or framework...
Read more >Property or Method is Not Defined - Michael Thiessen
Chances are if you've been developing with Vue for any amount of time, you've gotten this error: Most of the time this error...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found a way to fix the “Vue not defined” error without importing Vue and thus not bloating the ES5 distribution.
@pstephan1187
Why would you require Vue object to be registered globally? That’s the opposite to the idea how isolated components work - they should declare all their dependencies internally. You could add
@import Vue from 'vue';
in your component and the problem would be gone. It would make your component (library) easier to use - nobody would have to remember/read docs to know that to use it you have to have some global variables declared. It would also save people (like me) who try to write fully modular applications - without declaring any global variables - from polluting the code with some global variable only to use a single library.It’s like old JQuery days, when to use a JQuery plugin, you’d have to have
$
/JQuery
defined as a global variable. JavaScript has grown since then. So should we in how we build our tools.