vue里面写法如下:
export default function ({ isServer, req, redirect, route }) { let pcOrigin = 'https://www.xxxxx.com' let mobileOrigin = 'https://m.xxxxx.com' let isMobile = (ua) => { return !!ua.match(/AppleWebKit.*Mobile.*/) } let userAgent = req ? req.headers['user-agent'] : navigator.userAgent || '' if(route.params.novel_id || route.params.comic_id) { return isMobile(userAgent) ? redirect(mobileOrigin + route.fullPath) : '' } else { if(/ipad/i.test(userAgent)){ // 不包含ipad return } else { return isMobile(userAgent) ? redirect(mobileOrigin + '/app') : '' } } // return isMobile(userAgent) ? redirect(mobileOrigin + route.fullPath) : '' // 使用redirect 重定向到外链需要加上前缀:http / https }