0

以下のコードを書きました:

<script type="text/javascript">
function testGenerator()
{
yield "first";
document.write("step1");
yield "second";
document.write("step2");
yield "third";
 document.write("step3");
 }
 var g = testGenerator();
document.write(g.next());
document.write(g.next());
 </script>

私の望ましい出力:step1step2 しかし、上記のコードは私のhtmlには何も表示されません。ここで私が犯した間違いを理解するのを手伝ってくれる人はいますか。

ありがとう

4

1 に答える 1

2

ジェネレータ/イテレータは現在Firefoxでのみサポートされてtypeおり、それらを使用するには、スクリプトタグの属性をに変更する必要があります"text/javascript;version=1.7"

于 2012-11-10T18:11:05.600 に答える