在我的应用程序中,图片的 html 保存在itemConfig.picture
如果我将以下代码添加到 js:
$('.picture').html(itemConfig.picture);
带有类图片的 div保持为空。但这一个有效:
var tmpVar='<div class="field field-name-field-picture field-type-image field-label-hidden"><div class="field-items"><div class="field-item even"><img typeof="foaf:Image" src="http://localhost/ae/sites/default/files/DSC_02911_0.jpg" width="130" height="120" alt="" /></div></div></div>'
$('.picture').html(tmpVar);
这些信息会很有用:
alert(typeof itemConfig.picture); // returns "String"
alert(itemConfig.picture); // returns <div class="field field-name-field-picture field-type-image field-label-hidden"><div class="field-items"><div class="field-item even"><img typeof="foaf:Image" src="http://localhost/ae/sites/default/files/DSC_02911_0.jpg" width="130" height="120" alt="" /></div></div></div>
为什么传递对象属性不起作用?