export default { mounted() { this.getDeviceType() }, data() { return { // 设备类型pc,ios,android deviceType: 'pc' } }, methods: { /** * 设备判断 */ getDeviceType() { const strCookie = document.cookie; //将多cookie切割为多个名/值对 const arrCookie = strCookie.split("; "); let xAPP = ""; //遍历cookie数组,处理每个cookie对 for(let i=0; i { if (item) { const it = item.split('='); if (it[0] === 'x_app' || it[0] === 'x_access_token') { sign[it[0]] = it[1]; } } }); } return sign; }, /** * get cookie */ getCookie() { const cookie = {}; if (document && document.cookie) { document.cookie.split(/; ?/).forEach(item => { if (item) { const it = item.split('='); cookie[it[0]] = it[1]; } }); } return cookie; } } }