Không bao gồm bất kỳ cú pháp vuejs nào trong tệp HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>My Super app</title>
</head>
<body>
<div id="app"></div>
<script src="/app.js"></script>
</body>
</html>
Trong JavaScript chính của bạn, bạn có thể:
import Vue from 'vue'
import App from './App'
new Vue({
el: '#app',
components: { App },
template: '<App/>'
})
Xem mẫu webpack vuetify để tham khảo.
Một giải pháp khác là sử dụng:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>My Super app</title>
</head>
<body>
<div id="app" is="App"></div>
<script src="/app.js"></script>
</body>
</html>
Với:
import Vue from 'vue'
import App from './App'
Vue.component("App", App);
const app = new Vue({});
window.addEventListener("load", async () => {
app.$mount("#app")
})
[v-cloak] { display: none; } <div v-cloak> {{ message }} </div>
có nghĩa là, tôi nên thêmv-cloak
thuộc tính trong mọi phần tử mà II muốn ẩn?