Ich benutze Vibed Server. Es benutzt Pug Preprocessor (vorher bekannt als Jade). Hier ist meine Seite Code:Pug (Jade) Basis HTML Seite: Kann Element nicht finden: #app
doctype html
html
head
script(src="https://unpkg.com/vue")
script(src="app.js")
title Hello, World
body
h1 Hello World
#app
|{{message}}
Es erzeugt nächste HTML-Ausgabe:
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/vue"></script><script src="app.js"></script><title>Hello, World</title>
</head>
<body>
<h1>Hello World</h1>
<div id="app">
{{message}}
</div>
</body>
</html>
Mein app.js Code:
window.onload = function() {
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
});
app.$mount('#app');
}
Aber es ist nicht funktionieren. In der Browser-Konsole bekomme ich nächsten Fehler: Cannot find element: #app
upd: Verschieben script(src="app.js")
nach unten half. Aber gibt es eine bessere Variante? Oder es ist in Ordnung?