[英]How to add content in property dynamically?
I have this code:我有这个代码:
var fileInput = $("#input-id").fileinput({
initialPreview: [
"<img src ='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png' style='width:213px;height:141px;' name='Google'>",
],
});
I want to add more img
's (that I get from a JSON) to the initialPreview property, but I do not see how to access it.我想向 initialPreview 属性添加更多img
(我从 JSON 获得),但我看不到如何访问它。 I do not even know how to make a log console of this property.我什至不知道如何制作这个属性的日志控制台。
Declare initial Data as:将初始数据声明为:
var data = {
initialPreview: [
"<img src ='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png' style='width:213px;height:141px;' name='Google'>",
],
};
Now you fileinput will be现在你的文件输入将是
var fileInput = $("#input-id").fileinput(data);
When you get more value eg.当您获得更多价值时,例如。 new_img_data from JSON then来自 JSON 的 new_img_data 然后
data.initialPreview.push(new_img_data)
now reload:现在重新加载:
$("#input-id").fileinput(data)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.