全栈之巅笔记第三部分-分类列表
对应视频P7 https://www.bilibili.com/video/BV1A4411Y7fi?p=7
目标:接上节CategoryEdit.vue中this.$router.push('/categories/list')
完成这个list
(1)前端页面
将home.vue复制为CategoryList.vue
然后router/index.js里import并加入路由(Children里),注意这是增加页面的基本套路
然后里还要增加列表的表格
最后下面
(2)后台接口
server/routes/admin/index.js里增加接口:
router.get('/categories',async(req,res) =>{
const items = await Category.find().limit(10) //必须在index.js中加个中间件
res.send(items)
})