在Firefox中使用let和yield [英] Using let and yield in Firefox
问题描述
我正在尝试在Firefox中使用 let
和 yield
。我正在测试18和21版本(每晚)并获得相同的结果。
I'm trying to use let
and yield
in Firefox. I am testing in both versions 18 and 21 (Nightly) and getting the same results.
这是我非常简单的测试脚本:
Here's my really simple test script:
<html>
<head>
<title>test</title>
<script type="text/javascript">
'use strict';
function a() {
yield 5;
}
</script>
</head>
<body></body>
</html>
我收到此错误:
< img src =https://i.stack.imgur.com/WGjDD.pngalt =yield是一个保留标识符>
同样当我做一个使用进行简单测试
我得到让它是一个保留标识符,这实在令人沮丧,因为让
自版本2以来一直存在于Firefox中!
Similarly when I do a simple test with let
I get "let is a reserved identifier", which is really frustrating because let
has supposedly existed in Firefox since version 2!
奇怪的是,如果我在Firebug中执行相同的代码就行了!
Strangely, if I execute the same code in Firebug it works!
我在中尝试过各种其他字符串键入
和语言
脚本
标签的属性,但是没有找到有效的魔术标签。
I have tried various other strings in the type
and language
attributes of the script
tag but have not found a magic one that works.
发生了什么事?如何使用脚本标记来处理这些内容?
What's going on? How do I get this stuff working with a script tag?
嗯,我明白了,所以你必须指定版本号。我试过这个,但对于我原来使用网络工作者的更复杂的脚本。显然在脚本上使用 version = 1.7
,该脚本包含一个web worker,其中包含一个使用 let
和<$ c的脚本$ c> yield 不够好 - 网络工作者脚本仍然破坏...然后我尝试减少到最简单的情况但显然没有尝试 version = 1.7
最简单的情况。
Hmm, I see, so you must specify the version number. I had tried this, but for my original more complicated script which used web workers. Apparently using version=1.7
on a script which includes a web worker which includes a script that uses let
and yield
isn't good enough -- the web worker script still breaks... Then I tried reducing to simplest case but apparently didn't try version=1.7
in simplest case.
谢谢......可能会稍微发布另一个问题(搜索后)如何让网络工作者工作。
Thanks... Might post another question in a little bit (after searching) on how to get this working for web workers.
推荐答案
as mdn note ,
yield关键字仅适用于代码块HTML包含在
< script type =application / javascript; version = 1.7>
块(或更高版本)
所以将< script type =text / javascript>
更改为<脚本类型=应用/ JavaScript的;版本= 1.7>
将使其正常工作。
So changing <script type="text/javascript">
to <script type="application/javascript;version=1.7">
will make it work.
这篇关于在Firefox中使用let和yield的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!