Cannot find element: #App

Posted miaomiaotab

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cannot find element: #App相关的知识,希望对你有一定的参考价值。

瞎找了一天都没找到问题所在(问题代码

/* eslint-disable no-new */
new Vue({
  el: \'#App\',
  router,
  template: \'<App/>\',
  components: { App }
})
// new Vue({// 全局构造函数
//   el: \'#app\', // 对象装载的位置
//   template: \'<App/>\',
//   router,
//   components: {
//     App
//   }
// })

  

 



f分割线


 


 

 

app.vue 正确代码

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <router-view/>
  </div>
</template>

<script>
export default {
  name: \'App\'
}
</script>

  

原来是小写的问题,el: \'#app\',id为app的元素,这个a字母是小写的!!!!!!!

main.js 正确代码

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

/* eslint-disable no-new */
new Vue({
  el: \'#app\',
  router,
  template: \'<App/>\',
  components: { App }
})

  

components\\Apple.vue

<template>
    <a >{{ msg }}</a>
</template>

<script>
export default {
  name: \'Apple\',
  data () {
    return {
      msg: \'I am an apple\'
    }
  }
}
</script>

  

router\\index.js

import VueRouter from \'vue-router\'
import Vue from \'vue\'
import Apple from \'@/components/Apple\'
import Banana from \'@/components/Banana\'

Vue.use(VueRouter)

export default new VueRouter({
  routes: [
    {
      path: \'/\',
      component: Apple
    },
    {
      path: \'/banana\',
      component: Banana
    }
  ]
})

  

以上是关于Cannot find element: #App的主要内容,如果未能解决你的问题,请参考以下文章

[vue遇错记录] vue.js:569 [Vue warn]: Cannot find element: #app

解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element

cvc-elt.1: Cannot find the declaration of element 'beans'Failed to read schema document '

Electron 发生错误 "Cannot find module app"的解决方案

Could not find a declaration file for module 'element-plus'.

APP定位元素几种方法