function createNew(mouseEventData) {
var measurementData = {
visible: true,
active: true,
toolType: 'target',
description: output
};
return measurementData;
}
function onImageRendered(e, eventData) {
var textline = ["Test"];
var obj = { "description":textline};
alert(obj)//[object Object]
var output = JSON.stringify(obj);
alert("output"+output); //output{"description":["Test"]}
}
在上面的代码片段中,我想将textline字符串数组传递给measurementData的description字段。 请帮我介绍如何将动态字符串数组传递给JSON对象 (文本行是动态数组)
答案 0 :(得分:0)
您可以使用全局变量:
var measurementData;
function createNew(mouseEventData) {
return measurementData;
}
function onImageRendered(e, eventData) {
var textline = ["Test"];
measurementData = {
visible: true,
active: true,
toolType: 'target',
description: textline
};
}