我有2个软件包,一个是当前软件包,另一个是非活动软件包。
我想使用if-else语句显示值。条件基于activeDate
属性,该属性具有字符串date,并且具有两个值(例如"20191210", ""
)。
[{
activeDate: "20190722",
buyType: "2",
deviceId: "89852420180910182245",
expireDate: "20200731"
}, {
activeDate: "",
buyType: "2",
deviceId: "89852420180910182245",
expireDate: "",
flow: "1000"
}, {
activeDate: "",
buyType: "2",
deviceId: "89852420180910182245",
expireDate: "",
flow: "1000"
}, {
activeDate: "",
buyType: "2",
deviceId: "89852420180910182245",
expireDate: "",
flow: "1000"
}]
$.each(response.data.tradeData, function(index, element) {
if (element.activeDate != '' || element.activeDate == '') {
// str += '<li><a onclick="getDetails(' + index + ')" href="javascript:void(0);">' + element.packageName + '</a></li>';
if (element.activeDate != '') {
str += '<li><a href="">' + element.packageName + '</a></li>';
$("#current-package").html(str);
} else if (element.activeDate == '') {
str += '<li><a>' + element.packageName + '</a></li>';
$("#inactive-package").html(str);
}
} else {
if (element.activeDate != '') {
str += '<li><a href="">' + element.packageName + '</a></li>';
$("#current-package").html(str);
$(".current-inactive-dp").hide();
} else {
str += '<li><a>' + element.packageName + '</a></li>';
$("#inactive-package").html(str);
$(".current-active-dp").hide();
}
}
});