如何在Aurelia中调用函数并将参数传递给switch语句?这是我的示例:
home.html
<template>
<input type="text" value.bind="FruitName">
<div class="Fruit">
<a href="http://www.example.com/${TypeOfFruit(FruitName)}" target="_blank"><a>
</template>
home.js
export class Home {
TypeOfFruit(fruits) {
text = ""
switch (fruits) {
case "Banana":
text = "Banana is good!";
break;
case "Orange":
text = "I am not a fan of orange.";
break;
case "Apple":
text = "How you like them apples?";
break;
default:
text = "I have never heard of that fruit...";
}
return this.text;
}
}