默认Angular-CLI项目在Safari中失败-罪魁祸首严格模式? [英] Default Angular-CLI Project Fails in Safari - culprit strict mode?

查看:118
本文介绍了默认Angular-CLI项目在Safari中失败-罪魁祸首严格模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了最新版本的angular-cli,并创建了一个全新的项目(ng new my-app).这将创建带有Angular徽标的始终时尚的"Welcome to App",并链接到环游英雄",CLI文档和Angular博客.我可以提供此服务,并使用Chrome和Firefox在Windows计算机上本地访问它.

I have installed the most-recent version of the angular-cli and created a brand new project (ng new my-app). This creates the always-stylish "Welcome to App" with the Angular logo and links to Tour of Heroes, the CLI Documentation, and the Angular blog. I can ng serve this and access it locally on my Windows machine using Chrome and Firefox.

当我尝试通过Browserstack访问相同的本地托管应用程序时,这变得很奇怪.当我从运行Safari 11的Mac上点击它时,一切正常.

Where this gets strange is when I try to access the same locally hosted app through Browserstack. When I hit it from a Mac running Safari 11, all works as expected.

但是,当我尝试通过运行Safari 10+的Mac设备(例如iPad)进行访问时,该应用将无法加载,并且收到错误消息:语法错误:意外的关键字'const'.不支持const声明在严格模式下".错误消息被绑定到我的vendor.bundle.js中的位置(在评估中).

However, when I try to access via a Mac device (iPad for example) running Safari 10+, the app will not load and I get the error message: "SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode". The error message is tied to a location in my vendor.bundle.js (in an eval).

从我的阅读中可以看出,启用严格模式后,较早版本的Safari不能与const配合使用.但是,我希望有一个解决方法.

From my reading, it appears that older versions of Safari don't play nice with consts when strict mode is enabled. But, I am hoping there is a work-around.

其他人如何处理呢?我不是angular-cli专家,所以如果有一个明显的解决方案,我很抱歉没有看到它.

How are others handling this? I am not an angular-cli expert, so if there is an obvious solution, my apologies for not seeing it.

任何帮助将不胜感激.

推荐答案

我遇到了同样的问题.似乎在webpack-dev-server(使用@ angular/cli在后台使用)中存在问题,该问题使用ES6功能并且未进行编译.

I have the same issue. It seems an issue in webpack-dev-server (used under the hood by @angular/cli) which uses ES6 features and is not being transpiled.

这只是旧版Safari中的问题,但是当您要在旧版Safari上进行测试时,更新Safari并不是解决方案.

This is only a problem in older versions of Safari, but updating Safari is not a solution when you want to test on older Safari versions.

一个临时解决方法是通过安装webpack-dev-server使用较旧的版本并将其手动复制到本地@ angular/cli目录:

A temporary workaround is to use an older version for webpack-dev-server by installing it and copying it manually to the local @angular/cli directory:

yarn add webpack-dev-server@2.7.1 --dev
cp -R ./node_modules/webpack-dev-server ./node_modules/@angular/cli/node_modules/
./node_modules/.bin/ng serve

这篇关于默认Angular-CLI项目在Safari中失败-罪魁祸首严格模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆