首页 新闻 会员 周边

Angular: 如何兼容低版本的 Chrome

0
悬赏园豆:30 [已解决问题] 解决于 2023-08-10 22:50

园子会员首页 的前端基于 angular 实现,现在发现低版本的 Chrome(比如 Chrome 78)访问时页面一篇空白,浏览器控制台显示错误 Uncaught SyntaxError: Unexpected token '?',请问如何解决?

dudu的主页 dudu | 高人七级 | 园豆:30994
提问于:2023-08-09 10:13
< >
分享
最佳答案
0

原来是少了 .browserslistrc 文件引起的,添加下面的 .browserslistrc 文件就解决了

# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# You can see what browsers were selected by your queries by running:
#   npx browserslist

> 0.5%
last 5 versions
Firefox ESR
Chrome >= 55
not dead
not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
not ios_saf 15.2-15.3
not safari 15.2-15.3
dudu | 高人七级 |园豆:30994 | 2023-08-10 22:50
其他回答(1)
0

方案一 使用 babel技术
支持将es6语法 转es5 支持低版本浏览器

方案二:动态加载angular.js文件,如果是低版本的 浏览器 使用 低版本的 angular.js

收获园豆:30
s_p | 园豆:138 (初学一级) | 2023-08-09 17:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册