【发布时间】:2019-03-04 15:42:15
【问题描述】:
我有一个表格,其中显示了我使用以下代码获得的项目列表:
interface getResources {
title: string;
category: string;
uri: string;
icon: string;
}
@Component
export default class uservalues extends Vue {
resources: getResources[] = [];
created() {
fetch('api/Resources/GetResources')
.then(response => response.json() as Promise<getResources[]>)
.then(data => {
this.resources = data;
});
}
}
}
这是我的桌子:
<div class="panel panel-default">
<div class="panel-heading" style="font-weight:bold"><span class="glyphicon glyphicon-align-justify"></span> All Resources</div>
<div class="row">
<div class="search-wrapper panel-heading col-sm-12">
<input class="form-control" type="text" v-model="searchQuery" placeholder="Search" />
</div>
</div>
<div class="panel-body" style="max-height: 400px;overflow-y: scroll;">
<table v-if="resources.length" class="table">
<thead>
<tr>
<th>Resource</th>
</tr>
</thead>
<tbody>
<tr v-for="item in resources">
<td><a v-bind:href="item.uri" target="_blank">{{item.title}}</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
我正在尝试实现为用户过滤结果的搜索栏,但我迷路了!
有什么建议吗?
【问题讨论】:
-
您希望在输入例如
B时拥有以B 开头的项目? -
对不起!是的,这就是我想要的
-
我不熟悉打字稿,但我可以使用通常的 Vue 代码给出解决方案
-
太好了!我很感激
标签: javascript typescript vue.js vuejs2 vue-component