Vue路由注意事项
一、vue中路由的使用 1、定义组件 <template> <div class="hello"> <h1 @click="info" :class="color">{{ msg }}</h1> </div> </template> <script> export default { name: 'hello', data () { return { msg: '我是Hello组件', color:'color' } }, methods:{ info(){ console.log('你点击了我'); } } } </script> <style> .color{ color:#630; } </style> 2、配置路由文件 import Vue from 'vue' import Router from 'vue-router' import Hello from '@/components/Hello' import Word from '@/components/Word'; Vue.use(Router) export default new Router({ routes: [ { path: '/', component: Hello }, { path:'/index', component:Word } ] }) 3、配置路由插座<router-view><