当前位置: 首页 > news >正文

龙凤网站建设云聚达wordpress修改样式

龙凤网站建设云聚达,wordpress修改样式,100个新公司起名,烟台网站推广广州公司Vue3代码 APP文件中写入js代码 1、首先#xff0c;通过isMobile()函数判断用户的设备类型。该函数使用正则表达式匹配navigator.userAgent字符串#xff0c;以确定用户是在移动设备上访问网页还是在桌面设备上访问网页 2、然后#xff0c;在onMounted()钩子函数中#…  Vue3代码  APP文件中写入js代码 1、首先通过isMobile()函数判断用户的设备类型。该函数使用正则表达式匹配navigator.userAgent字符串以确定用户是在移动设备上访问网页还是在桌面设备上访问网页 2、然后在onMounted()钩子函数中根据当前的路由路径来判断是否需要进行重定向。如果当前路径是根路径(/)或移动端首页路径(/mobile_index)则会进一步检查设备类型。 3、如果是移动设备则通过router.replace(/mobile_index)将路由重定向到移动端首页。如果是桌面设备则通过router.replace(/)将路由重定向到桌面端首页。 script setup langts import { onMounted } from vue; import { useRouter, useRoute } from vue-router const router useRouter() const route useRoute() const isMobile () {let flag navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)return flag; }onMounted(() {if (route.path / || route.path /mobile_index) {if (_isMobile()) {router.replace(/mobile_index)} else {router.replace(/)}} })router中写法 import type { RouteRecordRaw } from vue-router export const staticRoutes: ArrayRouteRecordRaw [// pc{path: /,component: () import(../views/pc_index.vue),redirect: /home,children: [{path: /home,name: Home,component: () import(../views/home/index.vue),meta: {title: 首页,icon: ele-HomeFilled,},},// 公司产品{path: /companyProducts,name: companyProducts,redirect: /companyProducts/coalAR,children: [{path: /companyProducts/coalAR,name: coalAR,component: () import(../views/companyProducts/coal/coalAR/index.vue),}],},],},// 手机端首页{path: /mobile_index,component: () import(../views/mobile_index.vue),redirect: /mobileIndex,children: [{path: /mobileIndex,name: mobileIndex,component: () import(../views/mobile/mobileIndex.vue),meta: {title: 首页,icon: ele-HomeFilled,}},// 公司产品{path: /mobileProducts,name: mobileProducts,redirect: /mobileProducts/coalAR,children: [{path: /mobileProducts/coalAR,name: mobileCoalAR,component: () import(../views/mobile/mobileProducts/coal/coalAR/index.vue),}]}]}, ] Vue2写法 在 App.vue 的 mounted 方法中对设置进行判断如下: //App.vue mounted() {if (this._isMobile()) {alert(手机端);this.$router.replace(/m_index);} else {alert(pc端);this.$router.replace(/pc_index);}} methods:{isMobile () {let flag navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)return flag; } } /在 router/index.js 中有两个页面。 //在 router/index.js 中有两个页面。 export default new Router({mode: history,routes: [{path: ,redirect: /pc_index},{path: /pc_index, // pc端首页name: PcIndex,component: PcIndex},{path: /m_index, // 手机端首页name: MIndex,component: MIndex}] });参考vue2链接地址【Vue】判断设备是移动端还是pc端_vue判断是pc端还是移动端-CSDN博客
http://www.pierceye.com/news/351724/

相关文章:

  • 有免费注册网站吗做教育网站还挣钱吗
  • 网站做百度推广需要哪些条件店铺推广软文范例
  • 台州企业网站搭建特点迅美网站建设
  • 做营销网站推广官方网站建设方法
  • 网页设计精选网站网站查询功能怎么做
  • 重庆专业网站推广流程建立平台的步骤
  • 舟山市普陀区建设局网站net网站开发 兼职
  • 网站备案流程阿里云南宁网站建设官网
  • h5网站制作介绍简单的静态 新闻 asp 网站源码
  • 济南seo网站推广公司帮别人做彩票网站吗
  • 郑州市网站建设怎么样wordpress wp editor
  • 台州网站建设 推广公司网络营销课程总结范文
  • 网站 外包 版权杭州做官网的有哪些公司
  • 微信网站html5中山平面设计公司
  • 建站网站教程视频世界网站排名
  • 做小程序的流程seo 整站优化
  • 网站前台代码国内网站主机
  • 网站后台asp源码高明顺德网站建设
  • 网站建设推广软文网络规划设计师考试全程指导(第2版) pdf
  • 备案网站多少钱支持wordpress的空间
  • 哈尔滨网页模板建站wordpress网页设定
  • 哔哩哔哩网站怎么做视频软件进入公众号会不会泄露个人信息
  • 域名过期做的网站怎么办wap网站前景
  • 网站设计公司 宁波少儿编程课
  • 建设信用卡银行积分商城网站网站关键词优化培训
  • 网站建设对电子商务的意义深圳网站设计兴田德润简介
  • 门设计的网站建设北京最大专业网站建设
  • 黄埔建网站公司长沙 网页制作
  • 网站页面海珠网站建设方案
  • 东宁网站制作公司产品彩页设计