<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./js/vue.js"></script>
<style>
h1{
font-size: 36px;
color:#d7567f;
text-align: center;
}
.tableStyle{
min-width:400px;
margin:15px auto;
border:0;
}
.tableStyle th{
background-color: #d7567f;
}
.tableStyle,.tableStyle th,.tableStyletd{
font-size: 0.95em;
text-align: center;
padding:4px;
border-collapse: collapse;
}
.tableStyle th,.tableStyletd{
border:1px solid #e89eb5;
border-width: 1px 0 1px 0;
}
.tableStyle tr{
border:1px solid #e89eb5;
}
.tableStyle tr:nth-child(odd){
background-color: #f1c6d4;
}
.tableStyle tr:nth-child(even){
background-color: #fdfdfd;
}
.btn{
margin:10px auto;
text-align: center;
}
</style>
</head>
<body>
<div id="app">
<h1>图书表格</h1>
<div class="btn">
<label for="keyName">请输入搜索关键字</label>
<input type="text" id="keyName" v-model="keyword"><br><br>
<button @click="sortType=1">按价格降序</button>
<button @click="sortType=2">按价格升序</button>
</div>
<table class="tableStyle">
<tr>
<th>序号</th>
<th>书名</th>
<th>价格</th>
</tr>
<tr v-for="(item,index) in filBooks" :key="item.bookId">
<td>{{index+1}}</td>
<td>{{item.bookName}}</td>
<td>{{item.price}}</td>
</tr>
</table>
</div>
<script>
new Vue({
el:"#app",
data:{
keyword:"",//搜索关键字绑定
sortType:0,//排序方式,0表示原顺序,1表示降序,2表示升序
books:[
{bookId:"001",bookName:"Vue.js开发实战",price:45},
{bookId:"002",bookName:"JavaScript提高",price:32},
{bookId:"003",bookName:"jQuery项目实战",price:25},
{bookId:"004",bookName:"Vue.js入门与提高",price:42},
{bookId:"005",bookName:"HTML+CSS3网页设计",price:36},
{bookId:"006",bookName:"微信小程序开发",price:36},
{bookId:"007",bookName:"HTML+CSS3项目实战",price:39},
{bookId:"008",bookName:"jQuery案例教程",price:40},
{bookId:"009",bookName:"小程序跨平台开发",price:52},
]
},
computed:{
// 所有字符串都包含空字符串,不是vue实例管理的方法,最好定义成箭头函数
filBooks:function(){
var arr = this.books.filter(item=>{
return item.bookName.indexOf(this.keyword)!=-1;
})
// console.log(arr);
if(this.sortType){
arr.sort((book1,book2)=>{
return this.sortType===1 ? book2.price-book1.price : book1.price-book2.price;
})
}
return arr;
}
}
})
</script>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
v-for过滤和排序,购物车页面效果,笔记本
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共31个文件
png:16个
html:6个
js:5个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 32 0 下载量 57 浏览量
2022-03-15
12:48:34
上传
评论
收藏 1.35MB RAR 举报
温馨提示
v-for过滤和排序,购物车页面效果,笔记本
资源详情
资源评论
资源推荐
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
共 31 条
- 1
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![avatar](https://profile-avatar.csdnimg.cn/7b4701f94dbe477ea4c7e5461325896b_weixin_57037336.jpg!1)
橙西橙西
- 粉丝: 21
- 资源: 29
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
评论0