1.让中间件只在某个路由中使用
// 增加配置中间件
config.middleware = ['cors','compress','auth'];
/* 使用match只在news中使用 */
config.auth = {
match:'/news',
title:"this is middleware"
}
match也可以是一个函数
config.auth = {
match(ctx){
if(ctx.url == "/news" || ctx.url =="/shops"){
return true
}else{
return false
}
},
title:"this is middleware"
}