我有默认/硬编码选择选项(4个选项)和json数据。 由于缺少" SWIZ"在我的json obj。当我点击它时会产生奇怪的输出。你可以看到小提琴... https://jsfiddle.net/tffv2owp/6/我必须保持" SWIZ"由于某种原因选择框中的选项。 我需要" 0"当我选择" SWIZ"时,为所有范围项设置的值选择下拉列表中的选项。
gpio:
答案 0 :(得分:2)
分叉你的小提琴
https://jsfiddle.net/g81a10ze/1/
if(fData.length > 0){
this.filteredData = fData;
} else {
this.filteredData = [{ "country": "SWIZ", "mon": "JAN", "A": "0", "S": "0"},
{ "country": "SWIZ", "mon": "FEB", "A": "0", "S": "0"}]
}
答案 1 :(得分:1)
你可以试试这个:
if(fData.length > 0){
this.filteredData = fData;
} else {
this.filteredData = [{},{}];
}`
和html
<tr>
<td>{{selectedCountry=='SWIZ'?0:month.A}}</td>
</tr>
<tr>
<td>{{selectedCountry=='SWIZ'?0:month.S}}</td>
</tr>