[Vue警告]:找不到元素:#app Express

问题描述 投票:0回答:1

在新项目中,我的应用程序没有在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。

谢谢你的帮助

express webpack vuejs2 babel-loader
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)
})
© www.soinside.com 2019 - 2024. All rights reserved.