1、当手机的链接和 pc 的链接都是一样的时候,只是手机地址前有 Mobile 时
1 2 3 4 5 6 7 8 9 10 11
   | <script>     if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {         var url = window.location.href;         var temp = url.match(/[^\/]+(\/)+[^\/]+\//g);         var point = temp ? Math.max(0, temp[0].length - 1) : -1;         var host = url.substring(0, point);         var others = url.substring(point);         var newurl = host + "/Mobile" + others;          location.replace(newurl);     } </script>
   | 
 
2、如果有很多链接不一样,还是老老实实地把手机网站的地址填上
1 2 3 4 5 6
   | <script>     if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {         var url = "http://m.domain.com";         location.replace(newurl);     } </script>
   | 
 
3、如果只是切换默认的模板,而不用带跳转链接的可以在 config 中默认模板进行动态修改
      
     
    
      
  
  
    
      
      
        
        致力于网站建设与Web开发。喜欢新事物,关注前后端动态,对新的技术有追求, 做一个优秀的web全栈工程师。