zoukankan      html  css  js  c++  java
  • 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 }
    })
    

      

    componentsApple.vue

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

      

    routerindex.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
        }
      ]
    })
    

      

  • 相关阅读:
    node.js开发 打包管理工具webpack
    node.js开发 npm包管理工具 npm 和 cnpm区别
    node.js开发 npm包管理工具
    node.js开发 1-概述
    脚手架-1概念
    前端开发 vue,angular,react框架对比2
    AttachDispatch
    画图软件orign的使用
    建立xml文件时遇到的编码问题和解决方法
    securecrt简介
  • 原文地址:https://www.cnblogs.com/tabCtrlShift/p/9162468.html
Copyright © 2011-2022 走看看