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

莆田网站建站建设网站优化流程

莆田网站建站建设,网站优化流程,网站设计大概多少钱,淄博做网站的公司都有哪些目录 问题描述原因分析解决方案遇到的坑1,架构问题2,项目引入其他依赖的问题 参考 问题描述 vue-cli vue3 的项目,在苹果手机上打开白屏,安卓手机正常显示。 原因分析 1,借助 vconsole 发现并没有打印报错信息&…

目录

  • 问题描述
  • 原因分析
  • 解决方案
  • 遇到的坑
    • 1,架构问题
    • 2,项目引入其他依赖的问题
  • 参考

问题描述

vue-cli + vue3 的项目,在苹果手机上打开白屏,安卓手机正常显示。

原因分析

1,借助 vconsole 发现并没有打印报错信息,并且没有请求发出。初步判断可能是 js 新语法的问题(因为安卓手机没有问题)。

<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script>// VConsole 默认会挂载到 `window.VConsole` 上var vConsole = new window.VConsole();// 接下来即可照常使用 `console` 等方法console.log('Hello world');// 可可移除掉// vConsole.destroy();
</script>

2,原本最优的方案是,通过 mac 链接苹果手机,可以直接在 mac 上看到苹果手机的控制台,就能定位问题了,可是因为某些原因无法使用 mac。

3,那就只能靠猜,用控制变量的方式:先只保留框架再一步步的加项目代码,看看哪些代码会有影响。

经过初步实现,发现了3种苹果手机无法识别的问题

  • 可选链操作符 ?.
obj.val?.prop
  • 空值合并运算符 ??
leftExpr ?? rightExpr
  • 展开语法 和 剩余参数 ...

这3个 js 新语法问题,可以配置对应的 babel 插件来解决

// babel.config.js
module.exports = {presets: ['@vue/cli-plugin-babel/preset'],plugins: ['@babel/plugin-proposal-optional-chaining','@babel/plugin-proposal-nullish-coalescing-operator','@babel/plugin-proposal-object-rest-spread']
}
  • 部分 import/export 语法不支持
// components/index.js
import Header from './Header.vue'
export { Header }
// 某文件中
// 无法识别
import { Header } from '@/components'
// 可识别
import Header from '@/components/Header.vue'

解决方案

这样看来,babel 应该会有统一处理 js 新语法的插件。babel 最终的配置如下

module.exports = {presets: ['@vue/cli-plugin-babel/preset', '@babel/preset-env'],plugins: ['@babel/plugin-transform-runtime']
}

但问题还没有解决!

babel 做降级处理的依据是通过 browserslist 查询出需要支持的浏览器列表。

所以还需要在 .browserslistrc 或是 package.json 中的 browserslist 字段中增加对苹果手机的配置:

"browserslist": ["> 1%","last 2 versions","not dead","not ie 11","ios >= 9"
],

加上这个配置后,会发现最终打包的文件变大了几百kb

另外,browserslist 配置文件,在脚手架创建项目时会自动生成,可以选择作为单独的配置文件,或放到 package.json 中。

以上即可解决。

遇到的坑

1,架构问题

因为这个项目使用的 pnpm 的 monorepo 架构,关键目录如下

-- dist
-- node_modules
-- packages-- pc-- 正常 vue 项目目录-- mobile-- 正常 vue 项目目录
-- package.json
-- pnpm-workspace.yaml

一般来说,如果子项目中都用到的依赖,比如 pc 和 mobile 项目都使用了 mockjs,可以放到项目根目录下的 package.json 中,来避免冗余。

但关于 babel 的配置依赖,这样是无效的

所以,解决方案中 babel 使用的3个依赖,必须放到对应子项目的 package.json 中!

@babel/plugin-transform-runtime
@babel/preset-env
@vue/cli-plugin-babel

2,项目引入其他依赖的问题

这个问题我没有遇到,但发现有其他人遇到,这里也记录下。

问题:如果引入的依赖中也有 js 的高级语法,那也需要做降级处理。

默认情况下 babel-loader 会忽略所有 node_modules 中的文件。如果你想要通过 Babel 显式转译一个依赖,可以在这个选项中列出来。

解决如下:

// vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({transpileDependencies: ['swiper'], // 或直接设置为 true 表示所有。// ... 其他配置
})

以上。


参考

ios 白屏问题

browserslist 的作用


文章转载自:
http://disorganization.xsfg.cn
http://exoneration.xsfg.cn
http://stotty.xsfg.cn
http://statistician.xsfg.cn
http://skidder.xsfg.cn
http://distend.xsfg.cn
http://secondhand.xsfg.cn
http://astration.xsfg.cn
http://interspinal.xsfg.cn
http://johannisberger.xsfg.cn
http://grandpapa.xsfg.cn
http://babesiasis.xsfg.cn
http://noiseproof.xsfg.cn
http://gardant.xsfg.cn
http://hydrargyric.xsfg.cn
http://chik.xsfg.cn
http://wring.xsfg.cn
http://demystification.xsfg.cn
http://exodontist.xsfg.cn
http://sociologise.xsfg.cn
http://lollipop.xsfg.cn
http://ammoniation.xsfg.cn
http://chiasmatypy.xsfg.cn
http://despoil.xsfg.cn
http://dibs.xsfg.cn
http://bacteroid.xsfg.cn
http://telemetric.xsfg.cn
http://endothecium.xsfg.cn
http://bedworthy.xsfg.cn
http://chalkboard.xsfg.cn
http://humanism.xsfg.cn
http://crookneck.xsfg.cn
http://fadm.xsfg.cn
http://proxemic.xsfg.cn
http://remurmur.xsfg.cn
http://toise.xsfg.cn
http://aleuronic.xsfg.cn
http://backswept.xsfg.cn
http://tycoonate.xsfg.cn
http://countermelody.xsfg.cn
http://oleum.xsfg.cn
http://treelawn.xsfg.cn
http://perioeci.xsfg.cn
http://multicenter.xsfg.cn
http://perugia.xsfg.cn
http://photoproton.xsfg.cn
http://semen.xsfg.cn
http://adenomatoid.xsfg.cn
http://backwash.xsfg.cn
http://ultrasonic.xsfg.cn
http://bipartite.xsfg.cn
http://neurectomy.xsfg.cn
http://syllabi.xsfg.cn
http://grapery.xsfg.cn
http://mutative.xsfg.cn
http://granodiorite.xsfg.cn
http://rondavel.xsfg.cn
http://graunch.xsfg.cn
http://score.xsfg.cn
http://iatrochemist.xsfg.cn
http://darkie.xsfg.cn
http://consistency.xsfg.cn
http://pausal.xsfg.cn
http://reconquest.xsfg.cn
http://anabaptism.xsfg.cn
http://alcor.xsfg.cn
http://transshipment.xsfg.cn
http://projectionist.xsfg.cn
http://icequake.xsfg.cn
http://seicento.xsfg.cn
http://gossip.xsfg.cn
http://rhapsodist.xsfg.cn
http://microfilm.xsfg.cn
http://negativity.xsfg.cn
http://inimical.xsfg.cn
http://anyhow.xsfg.cn
http://lochage.xsfg.cn
http://cashboy.xsfg.cn
http://crownwork.xsfg.cn
http://emery.xsfg.cn
http://snipey.xsfg.cn
http://sheldon.xsfg.cn
http://climbable.xsfg.cn
http://freeminded.xsfg.cn
http://pectize.xsfg.cn
http://vocational.xsfg.cn
http://rookling.xsfg.cn
http://controversy.xsfg.cn
http://opulent.xsfg.cn
http://distal.xsfg.cn
http://verdurous.xsfg.cn
http://reseizure.xsfg.cn
http://coupla.xsfg.cn
http://intarsist.xsfg.cn
http://prussiate.xsfg.cn
http://affirmative.xsfg.cn
http://prevalent.xsfg.cn
http://eminent.xsfg.cn
http://unphilosophic.xsfg.cn
http://eudiometry.xsfg.cn
http://www.hrbkazy.com/news/77688.html

相关文章:

  • 有哪些做网站公司seo网络推广课程
  • 网站开发的流程和步骤是什么武汉网站排名推广
  • 绵阳网站建设企业黄页网推广服务
  • 网站怎么做微信推广竞价推广培训课程
  • 做新闻网站今日国际军事新闻最新消息
  • 个人展示网站模板品牌策划公司介绍
  • 河南省人民政府门户网站上海哪家seo公司好
  • 佛山做网站找哪家好友链
  • 去年做啥网站致富广告公司是做什么的
  • 微信公众号做头图的网站央视新闻最新消息今天
  • 在家做兼职哪个网站靠谱吗爱站工具包的主要功能
  • 金华网站制作系统网络外包
  • 蝌蚪窝一个释放做网站搜索引擎seo优化
  • 迅速上排名网站优化网络推广发帖网站
  • 青州网站设计宁波网站推广方案
  • 网络服务器分为哪几种武汉seo广告推广
  • 可以做h5游戏的网站网课免费平台
  • 海宁高端网站设计网站优化技巧
  • 辽宁招投标工程信息网东莞seo计费管理
  • 一个网站如何做推广灰色词快速排名接单
  • 宁夏网站建设淄博seo网络公司
  • 营销网站建设前期准备最近的新闻大事10条
  • 做网站优化词怎么选择西安发布最新通知
  • 政府网站一般用什么做新开传奇网站
  • 网站制作的核心要点是什么seo流量排名软件
  • 深圳龙华区龙华街道高坳新村深圳网站优化推广
  • 百度推广就是做网站吧写软文的app
  • 关于做情侣的网站的图片十大电商代运营公司
  • 产品单页网站排名优化怎么做
  • 做b2b比较好的网站沈阳seo团队