I added my vue.js in the header but it has an error that says element root can't be found, because I have a div with an id of root.
But when I add it on the body everything works fine.
This is my js code.
new Vue({
el: '#root'
});
And this is my html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
</head>
<body>
<div id="root">
<task-list>
</task-list>
</div>
</body>
</html>
you need to import your vue js library at the bottom part of your body because your #app HTML container needs to be loaded first before it can be analysed by vue js.
<body>
<div id="app">
</div>
<script src="vue.js"></script>
</body>
Hi I didn't see any included js(except for vue package) in your html. But I think the solution is to place your script in footer.
Also if that doesnt work place it inside window.onload
window.onload = function() {
new Vue({
el: '#root'
});
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With