Not a duplicate: already check this question and this one; didn't get any clue. Some of similar ones are related to Laravel.
Can't figure out what was changed in my project, making [Vue warn]: Cannot find element: #app
appear.
The structure:
index.html: hosts the <div id="app">
:
[HEADER]
<div id="app" v-cloak></div>
[FOOTER]
main.js:
import Vue from 'vue';
import Users from './Users.vue';
import App from './App.vue'; // (1)
import Home from './Home.vue'; // (2)
import VueRouter from 'vue-router'; // (3)
Vue.use(VueRouter);
const routes = [
{path: '/users', component: Users},
{path: '/', component: Home}
];
const router = new VueRouter({
routes
});
new Vue({
el: '#app',
router,
render: h => h(App)
})
EDIT: when changed the last block to:
$(document).ready(function () {
new Vue({
el: '#app',
router,
render: h => h(App)
})
})
it didn't help either.
App.vue:
<template>
<router-view>
</router-view>
</template>
<script>
export default {
data () {
return {
message: "Test message"
}
}
}
</script>
Home.vue:
<template>
[contents]
[router-links]
</template>
<script>
[data]
[methods]
</script>
Whenever I get to the index page, the Vue warn gets displayed. One of attached questions I checked suggested that the DOM element is not ready when scripts are running. Already tried to switch order of imports in main.js
(App, Home and VueRouter, as marked in comments), but with no success.
Any idea where to look for solution?