我想在 vue.js 中包含搜索栏。我对 vue 还很陌生。我需要在前端过滤数据。当我在脚本部分获取数据时,如何过滤数据。
这是我的代码:
<template>
<div>
<div class="search-wrapper panel-heading col-sm-12">
<input type="text" v-model="search" placeholder="Search" /> <br />
<br />
</div>
<table class="table" id="myTable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Category</th>
<th>Quantity</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr v-for="product in products" :key="product.id">
<td>{{ product.id }}</td>
<td>{{ product.name }}</td>
<td>{{ product.category }}</td>
<td>{{ product.quantity }}</td>
<td>{{ product.status }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
data() {
return {
products: []
};
}
};
</script>
Run Code Online (Sandbox Code Playgroud)