Failed to compile.哪里出现问题了 6-3

来源:6-4 Vue项目预热 - 单文件组件与Vue中的路由

Inuyasha__

2019-06-29

Failed to compile.

./src/router/index.js
Module not found: Error: Can’t resolve ‘@/pages/home/Home.vue’ in ‘C:\Users\Administrator\Desktop\travel\src\router’
@ ./src/router/index.js 3:0-41
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

App.vue

<template>
  <div id="app">
    <!-- 显示的是当前路由地址所对应的内容 -->
    <router-view/>
  </div>
</template>

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

<style>

</style>

Home.vue

<template>
    <div>home</div>
</template>

<script>
export default{
    name: 'Home'
}
</script>

<style>

</style>

index.js

import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/home/Home'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home
    }
  ]
})

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

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

// 路由就是根据网址的不同,返回不同的内容给用户
写回答

1回答

Inuyasha__

提问者

2019-06-30

已发现问题

0
0

Vue2.5-2.6-3.0开发去哪儿网App 零基础入门到实战

课程紧跟Vue3版本迭代,企业主流版本Vue2+Vue3全掌握

10675 学习 · 8191 问题

查看课程