我一直在尝试比较茉莉花中的两个javascript对象。但我收到错误对象读取没有方法调用。
describe("AutoEditor", function() {
var widgetList = ["widget1","widget2"];
var oldEdgeStructure = {};
oldEdgeStructure.SingleLink = [{"widget1":[{"EdgePosition":"s","WidgetID":"widget2"}]},
{"widget2":[{"EdgePosition":"n","WidgetID":"widget1"}]}];
it("read edges", function(done) {
require(['auto-editor'], function(EdgeStructures) {
var containerEl = $('#container');
var edgeStructures = EdgeStructures.readEdges(widgetList,containerEl);
expect(edgeStructures.SingleLink).toEqual(oldEdgeStructure.SingleLink);
done();
});
});
});
答案 0 :(得分:0)
收到错误是因为在将div附加到DOM之后我没有在正文中加载Edgestructures。米哈尔你是对的。在加载DOM内容并解决问题后,我刚刚添加了脚本标记,我在body标签中加载了我的库。