1.0 在pc项目app.vue
created() {
// 调用
this.goOrther();
},
methods: {
goOrther() {
var is_mobi =
navigator.userAgent
.toLowerCase()
.match(
/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i
) != null;
if (is_mobi) {
// 如果是移动端就跳转到移动端地址
let params = new URL(window.location.href).hash; // new URL 可以得到相关的地址详情
let baseurl = "http://localhost:8080/" + params; // 测试接口
// let baseurl = "http://www.td-button.com/" + params; // 线上接口
// 利用方法跳转到对应的页面
window.location.href = baseurl;
} else {
// 如果是pc 端就不用跳转到其他页面
// window.location.href = "http://172.20.10.3:8081/"
}
},
},
};
2.0 在移动端项目app.vue
created() {
// 网站跳转
this.goOrther();
},
methods: {
goOrther() {
var is_mobi =
navigator.userAgent
.toLowerCase()
.match(
/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i
) != null;
if (is_mobi) {
} else {
// 如果不是移动端就跳转到pc网址
let params = new URL(window.location.href).hash; // new URL 可以得到相关的地址详情
let baseurl = "http://localhost:8080/" + params; // 测试接口
// let baseurl = "http://www.td-button.com/" + params; // 线上接口
// 利用方法跳转到对应的页面
window.location.href = baseurl;
}
},
},
};