以下TaffyDB脚本成功输出整个数据库:
db().each(function (name){
var bodyType=(name["bodyType"]);
var category=(name["category"]);
var name2=(name["name2"]);
var photo=(name["photo"]);
var resource=(name["resource"]);
var caption=(name["caption"]);
output = document.getElementById("display");
output.innerHTML+="<div class='segment'><p class='title'>" + bodyType + ": " + name2 + "</p>" +
"<img class='pic' src='" + photo + "' width='150px'>" +
"<p class='caption'>" + caption + "</p>" +
"<p class='more'><a href='" + resource + "'>More</a></p></div>";
});
我的问题是如何过滤内容。该网站有以下代码:
db().filter({column:value});
如何更改顶部代码以进行集成?
db().filter({bodyType:buggy});
这不起作用:
db().each(function (name){
var bodyType=(name["bodyType"]);
var category=(name["category"]);
var name2=(name["name2"]);
var photo=(name["photo"]);
var resource=(name["resource"]);
var caption=(name["caption"]);
db().filter({bodyType:buggy});
output = document.getElementById("display");
output.innerHTML+="<div class='segment'><p class='title'>" + bodyType + ": " + name2 + "</p>" +
"<img class='pic' src='" + photo + "' width='150px'>" +
"<p class='caption'>" + caption + "</p>" +
"<p class='more'><a href='" + resource + "'>More</a></p></div>";
});
答案 0 :(得分:0)
以这种方式更改第一行:
db({bodyType:"Buggy"}).each(function (name){