【发布时间】:2019-09-02 02:12:52
【问题描述】:
我正在使用卡片来显示数据库中的数据,我想实现一个搜索过滤器来根据用户类型过滤数据。我不知道该怎么做,所以我只是按照 W3school 的一些教程进行操作。代码不起作用。到目前为止,这就是我所做的:
Vue 组件
<table class="table col-md-12" style="background-color:white;">
<thead class="thead white" style="background-color:#3F51B5">
<th>Unassigned
<input class="form-control w-50 float-right" type="text" id="myInput">
</th>
</thead>
<tbody>
<div class="card col-md-11 mt-3 mx-auto" v-for="(uStudent,index) in uStudents" v-bind:key="uStudent.student_id" id="myList">
<div class="card-body">
<div class="row">
<h6 class="card-subtitle text-muted col-md-1 my-auto">#{{index+1}}</h6>
<h6 class="card-subtitle text-muted col-md-2 my-auto">{{uStudent.student_id}}</h6>
<h6 class="card-subtitle text-muted col-md-6 my-auto">{{uStudent.student_name}}</h6>
<h6 class="card-subtitle text-muted col-md-2 my-auto">{{uStudent.company_state}}</h6>
<a href="" class="col-md-1" @click="setLectureFK(uStudent.student_id)"><i class="fas fa-user-plus"></i></a>
</div>
</div>
</div>
</tbody>
脚本
<script>
export default {
data () {
return {
uStudents:[],
}
},
methods:{
getUnassignedStudents(){
axios.get(`/api/internship/unassignedStudents/${this.$route.params.id}`).then(response => this.uStudents = response.data);
},
filter(){
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myList").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
}
},
mounted() {
this.filter();
console.log('Component mounted.')
}
}
【问题讨论】:
标签: php laravel vue.js eloquent