为什么在尝试生成 GOJS 图时在 IE11 中出现语法错误

Why do I get an syntax error in IE11 when trying to generate a GOJS diagram

我可以在 Chrome、Firefox、Safari 和 Microsoft Edge 中生成图表,但不能在 IE11 中生成。当我查看控制台时,它告诉我有两个问题:

1.) 'init' 未定义 2.) 语法错误

在初始化中我做了以下事情:

<script src="https://unpkg.com/gojs/release/go.js"></script>
<script src="/js/GenerateMap.js"></script>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        init();
    });
</script>

里面 GenerateMap.js 我有以下内容:

function init() {
var newString = document.getElementById("valueFromServer").value;
var GO = go.GraphObject.make;
....}

对于语法错误,它告诉我它在第 13 行。包含“)”的行:

myDiagram.nodeTemplateMap.add("",
    GO(go.Node, "Auto",
        // the entire node will have a light-blue background
        { resizable: false, width: 130, height: 80, background: "transparent" },
        { click: function (e, node) { var data = node.data; clicknode(data.key);} },
        GO(go.Shape, "RoundedRectangle", { fill: "white" },
            new go.Binding("fill", "isSelected", function (sel) {
                if (sel) return "lightgoldenrodyellow"; else return "white";
            }).ofObject("").makeTwoWay()),
        GO(go.TextBlock, "Default Text",
            { stroke: "grey", font: "11px sans-serif", maxLines: 4, overflow: go.TextBlock.OverflowEllipsis },
            new go.Binding("text", "name"),
        ),
        new go.Binding("location", "loc", go.Point.parse)
    ));

为什么这些问题只出现在 IE11 上?

        { stroke: "grey", font: "11px sans-serif", maxLines: 4, overflow: go.TextBlock.OverflowEllipsis },
        new go.Binding("text", "name"),

问题与上述代码有关,Binding方法末尾多了一个','符号,尝试去除。

下面的代码应该可以正常使用,尝试使用它。

myDiagram.nodeTemplateMap.add("",
    GO(go.Node, "Auto",
        // the entire node will have a light-blue background
        { resizable: false, width: 130, height: 80, background: "transparent" },
        { click: function (e, node) { var data = node.data; clicknode(data.key);} },
        GO(go.Shape, "RoundedRectangle", { fill: "white" },
            new go.Binding("fill", "isSelected", function (sel) {
                if (sel) return "lightgoldenrodyellow"; else return "white";
            }).ofObject("").makeTwoWay()),
        GO(go.TextBlock, "Default Text",
            { stroke: "grey", font: "11px sans-serif", maxLines: 4, overflow: go.TextBlock.OverflowEllipsis },
            new go.Binding("text", "name")
        ),
        new go.Binding("location", "loc", go.Point.parse)
    ));