0

在新项目中,我的应用在 expressJs 服务器上找不到带有 VueJS (2.5.13) 的根元素。

我的 index.html:

<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <div id="app"></div>
        <script src="dist/index.js"></script>
    </body>
</html>

我的 js 入口点:

import Vue from 'vue'
import App from './App'

new Vue({
   render: h => h(App)
}).$mount('#app')

还有我非常基础的 App.vue:

<template>
    <div>
        Hello the world
    </div>
</template>
<script>
    export default {
        name: 'app'
    }
</script>
<style>
</style>

我使用 babel-loader 和 webpack。我不明白为什么 Vue 找不到#appid。

谢谢你的帮助

4

1 回答 1

0
 <template>
   <div id="app"> <----- id="app"
     Hello the world
   </div>
 </template>

尝试将 id="app" 添加到 App.vue 中的 div

new Vue({
  el: '#app', <-------- el: '#app'
  render: h => h(App)
})
于 2018-03-02T09:59:55.017 回答