VUE2:页面未渲染



从VUE 2入门,而无需通过vue-router渲染。我没有在控制台上收到任何错误,所以我认为我缺少一些非常基本的东西。(应用程序组件只是随附安装的标准组件,因此应该很好。


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');

utaes.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>

相关内容

  • 没有找到相关文章

最新更新