如何使用switch语句隐藏div。以下是我要执行的操作,但是它将隐藏所有true或false的div。
home.html
<template>
<div repeat.for="color of colors">
<div show.bind="condition">
${TypeOfGreeting(color)}
</div>
<div>
</template>
home.js
export class Home {
condition;
TypeOfGreeting(color) {
let text = ""
switch (color) {
case "white":
text = "good morning!";
condition = true;
break;
case "black":
text = "good night!";
condition = true;
break;
case "orange":
text = "good evening!";
condition = true;
break;
case "red":
condition = false;
break;
case "blue":
condition = false;
break;
default:
condition = false;
text = "Error!";
}
return text;
}
}