Vue2:页面未呈现

Vue2: Page Is Not Rendered

开始使用 Vue 2,没有通过 vue-router 呈现任何内容。我没有在控制台中收到任何错误,所以我认为我缺少一些非常基本的东西。 (app 组件只是安装时附带的标准组件,所以应该没问题。


main.js

import Vue from 'vue';
import vuex from 'vuex';
import axios from 'axios';
import routes from './routes';
import VueRouter from 'vue-router';

Vue.use(vuex);
Vue.use(axios);
Vue.use(VueRouter);

let router = new VueRouter({
  mode: 'history',
  scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 },
  routes
});

new Vue({ router }).$mount('#app');

routes.js

import App from './App';

let routes = [
  { path: '', component: App },
  { path: '/', component: App }
];

export default routes;

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>App</title>
  </head>
  <body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

App.vue

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <hello></hello>
  </div>
</template>

<script>
import Hello from './components/Hello';

export default {
  name: 'app',
  components: {
    Hello
  }
};
</script>

版本

vue: 2.1.0 vue-router 2.1.1

缺少 index.html <router-view></router-view>