第一种:
App.vue
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1.0, user-scalable=no">
<title>vue</title>
</head>
<body>
</body>
</html>
app.js
const app = new Vue({
router,
nprogress,
...App
})
app.$mount('#app')
第二种:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1.0, user-scalable=no">
<title>vue</title>
</head>
<body>
<div id="app">
<router-view></router-view>
</div>
</body>
</html>
app.js
const app = new Vue({
router,
nprogress,
})
app.$mount('#app')
为什么第一种显示Cannot find element: #app ,而第二种可以?https://github.com/vuejs/vue-... 也是第一种写法,不知道哪里出了问题?
第一种,因为挂载的时候找不到id为app的元素
那个项目可以貌似因为是分客户端渲染和服务端渲染的