我想在返回的子文档中添加一个字段,如下所示:
// Get a reference to the image element
var elephant = document.getElementById("elephant");
// Take action when the image has loaded
elephant.addEventListener("load", function () {
var imgCanvas = document.createElement("canvas"),
imgContext = imgCanvas.getContext("2d");
// Make sure canvas is as big as the picture
imgCanvas.width = elephant.width;
imgCanvas.height = elephant.height;
// Draw image into canvas element
imgContext.drawImage(elephant, 0, 0, elephant.width, elephant.height);
// Get canvas contents as a data URL
var imgAsDataURL = imgCanvas.toDataURL("image/png");
// Save image into localStorage
try {
localStorage.setItem("elephant", imgAsDataURL);
}
catch (e) {
console.log("Storage failed: " + e);
}
}, false);
我可以通过{
"type": "product",
"code": "abc",
"team": "A1",
"modules": [{
"type": "module",
"code": "cde"
//Add a new field here
}]
}
在文档中添加新字段,但无法添加到子文档中。
这是我的Java代码:
Document.append()
有人可以帮忙吗?非常感谢提前!!!