<template><div><table><tr><td>编号</td><td>封面url</td><td>书名</td><td>作者</td><td>出版日期</td></tr><trv-for="item in books"><td>{{item.id}}</td><td>{{item.cover}}</td><td>{{item.title}}</td><td>{{item.author}}</td><td>{{item.date}}</td></tr></table></div></template><script>exportdefault{name:"Book",data(){// data是一个函数对象
return{books:[{id:1,cover:'https://i.loli.net/2019/04/10/5cadaa0d0759b.jpg',title:'红楼梦',author:'清婉儿',date:'2020-06-14'},{id:2,cover:'https://i.loli.net/2019/04/10/5cadaa0d0759b.jpg',title:'那一夜',author:'卓文君',date:'2020-06-14'},{id:3,cover:'https://i.loli.net/2019/04/10/5cadaa0d0759b.jpg',title:'飞上你的床',author:'上官飞燕',date:'2020-06-14'}]}}}</script><stylescoped></style>
importVuefrom'vue'importVueRouterfrom'vue-router'importHomefrom'../views/Home.vue'// 引入 Book.vue
importBookfrom'../views/Book'Vue.use(VueRouter)constroutes=[{path:'/',name:'Home',component:Home},{path:'/about',name:'About',// 下面这是 vue3 的写法,这里我们还用vue2的写法注册组件
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component:()=>import(/* webpackChunkName: "about" */'../views/About.vue')},{path:'/book',component:Book}]constrouter=newVueRouter({mode:'history',base:process.env.BASE_URL,routes})exportdefaultrouter