Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import VueResource from 'vue-resource'
  4. import App from './App'
  5. // 开启debug模式
  6. Vue.config.debug = true
  7.  
  8. Vue.use(VueRouter)
  9. Vue.use(VueResource)
  10.  
  11. // 定义组件, 也可以像教程之前教的方法从别的文件引入
  12. const Home = {template: '<div>This is homepage</div>'}
  13. const First = { template: '<div><h2>我是第 1 个子页面</h2></div>' }
  14. const Second = {template: '<div>2222222</div>'}
  15.  
  16. // 创建一个路由器实例
  17. // 并且配置路由规则
  18. const router = new VueRouter({
  19. mode: 'history',
  20. base: __dirname,
  21. routes: [
  22. {
  23. path: '/',
  24. component: Home
  25. },
  26. {
  27. path: '/first',
  28. component: First
  29. },
  30. {
  31. path: '/second',
  32. component: Second
  33. }
  34. ]
  35. })
  36.  
  37. // 现在我们可以启动应用了!
  38. // 路由器会创建一个 App 实例,并且挂载到选择符 #app 匹配的元素上。
  39. var app = new Vue(
  40. Vue.util.extend({ router }, App)
  41. ).$mount('#app')
  42.  
  43. export default {app}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement