我正在尝试将图像路径附加到img src属性,但src显示(未知)。从Database(I console.logged)成功检索图像路径。我不知道为什么不返回路径字符串。提前致谢
function loadData() {
dbHandler.dataBase.transaction(function (tx) {
tx.executeSql('SELECT * FROM Properties', [], function (tx, results) {
var len = results.rows.length, i;
var list="";
for (i = 0; i < len; i++){
$('#propertiesList').append(`<li>
<a onClick="fullDetails(${ results.rows.item(i).propertyRef})">
<img src="${propertyImg(results.rows.item(i).propertyRef)}">
<h2><strong>£ ${ results.rows.item(i).monthFee} Pcm </strong></h2>
<p>${ flatType (results.rows.item(i).bedQty)} ${ results.rows.item(i).propertyType} to rent in ${ results.rows.item(i).postcode}</p>
<p>${ results.rows.item(i).furnitureType}</p>
<p>${ results.rows.item(i).notes}</p>
<p>Listed on <strong> ${ results.rows.item(i).createdOn} by ${ results.rows.item(i).postedBy} </strong> </p>
<p class="ui-li-aside"><strong><a href=""> Available ${ results.rows.item(i).avalabilityDate}</strong></a></p>
</a>
</li>`).listview('refresh');
}
}, null);
});
function propertyImg(ref){
var myg="";
dbHandler.dataBase.transaction(function (tx) {
tx.executeSql('SELECT * FROM Propertyimages Where postRef =' + ref , [], function (tx, results) {
var ded = results.rows.length, i;
console.log(results)
var imgss="";
for (i = 0; i < ded; i++){
imgss += `${results.rows.item(i).imgPath}`;
}
myg = imgss
console.log(myg);
}, null);
})
return myg;
}
}