本来要做一个地址栏参数改变,显示相对应的Item列。
toDetermineParameters(OBJECT, PARAMETER) {
if (PARAMETER === "colorPage") {
OBJECT.ppt = null;
OBJECT.operationManual = null;
OBJECT.hardware = null;
OBJECT.plan = null;
return OBJECT;
} else if (PARAMETER === "ppt") {
OBJECT.colorPage = null;
OBJECT.operationManual = null;
OBJECT.hardware = null;
OBJECT.plan = null;
return OBJECT;
} else if (PARAMETER === "plan") {
OBJECT.colorPage = null;
OBJECT.operationManual = null;
OBJECT.hardware = null;
OBJECT.ppt = null;
return OBJECT;
} else if (PARAMETER === "operationManual") {
OBJECT.colorPage = null;
OBJECT.plan = null;
OBJECT.hardware = null;
OBJECT.ppt = null;
return OBJECT;
} else if (PARAMETER === "hardware") {
OBJECT.colorPage = null;
OBJECT.plan = null;
OBJECT.operationManual = null;
OBJECT.ppt = null;
return OBJECT;
} else if (!PARAMETER) {
return OBJECT;
} else if (!OBJECT[PARAMETER]) {
this.ishow = false;
}
},
然后我搞了一大长串判断,在问过大佬后 ,两行代码给我解决了。。
const CARD_TYPE = window.location.search.slice(1) || "showAll";
methods: {
pdfPage(title, head, num) {
localStorage.setItem("title-head", title + "-" + head);
window.location.href = "./pdf.html?file=" + num;
},
isShowItem(key) {
return this.pdfList[key] && [key, "showAll"].includes(CARD_TYPE);
},
changeIsShow() {
if (CARD_TYPE !== "showAll" && !this.pdfList[CARD_TYPE]) {
this.ishow = false;
}
},
},
<v-list-item v-ripple v-if="isShowItem('plan')">