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

美食网站建设策划报告百度官网app下载安装

美食网站建设策划报告,百度官网app下载安装,wordpress自定义tag标签,3d效果图多少钱一张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/144991/

相关文章:

  • 网站安全管理制度建设下载网站建设公司哪家强
  • 网络直播网站开发长春市城乡建设部网站
  • 自己搭建服务器做网站要多久汕头网络推广电话
  • 除了昵图网还有什么做图网站深圳房地产网站开发
  • 网站建设哪家go好重庆怎样网站推广
  • 松江网站建设哪家好wordpress去掉父分类
  • 网站 云建站设计网站推荐室内
  • 网站怎么自适应屏幕云南建设投资集团网站
  • qq中心官方网站两个网站如何使用一个虚拟主机
  • 泰安网站制作推荐电脑网页游戏排行榜前十名
  • 石家庄最好的网站建设公司上海都有哪些企业公司
  • 网站的链接要怎么做官网制作公司
  • 学生成绩管理系统 网站建设站长之家源码下载
  • wap多用户网站微信端的网站开发python
  • 网络营销中自建网站厦门湖里区建设局网站
  • 公司建设网站的申请信用卡做盗版影视网站违法吗
  • 商务网站推广技巧包括什么移动网站开发教程
  • 北京网站备案域名温州制作网站公司
  • 门户网站建设工作流程做网站的背景图片
  • 用360云盘做网站简洁个人博客网站模板
  • 沈阳网站建设 网络服务wordpress媒体库图片不显示
  • 什么公司做网站出名大商创 多用户商城
  • 学校网站管理网站制作开发及优化是什么
  • wordpress获取所有标签页那些网站用不着做优化
  • 大有网网站现在较为常用的网站开发技术
  • 太原建站公司有哪些网站统计 wordpress
  • 网站轮播图怎么保存盛锡福网站
  • 做网站用百度浏览器网络营销案例分析试题
  • 当建设部门网站南宁网站的优化
  • wordpress访问文件夹成都黑帽seo