当前位置:网站首页>品牌列表案例
品牌列表案例
2022-07-27 18:12:00 【宇智波-林中路】
增删查、过滤器
第1步:
npm init -y
生成 .json文件
第2步:
npm i bootstrap -S
生成2个文件
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap-grid.min.css"><!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="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
<link
rel="stylesheet"
href="./node_modules/bootstrap/dist/css/bootstrap.min.css"
/>
</head>
<body>
<div id="app">
<div>
<label>Id:</label>
<input type="text" v-model="id" />
<label>Name:</label>
<input type="text" v-model="name" />
<input
type="button"
value="添加"
class="btn btn-primary"
@click="add"
/>
<label>按照品牌名称取检索::</label>
<input type="text" v-model="keyWords" @change="searchByName" />
</div>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Ctime</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="(item,index) in searchByName()" :key="item.id">
<td>{
{item.id}}</td>
<td>{
{item.name}}</td>
<td>{
{item.ctime}}</td>
<td>
<!-- 避免用一元操作符作为属性名delete -->
<!--传索引 -->
<a href="http://www.baidu.com" @click.prevent="del(index)"
>删除</a
>
<!-- 传id -->
<!-- <a href="http://www.baidu.com" @click.prevent="del(item.id)"
>删除</a
> -->
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
<script>
const app = new Vue({
el: "#app",
data: {
id: "",
name: "",
keyWords: "",
list: [
{ id: 1, name: "奔驰", ctime: new Date() },
{ id: 2, name: "宝马", ctime: new Date() },
{ id: 3, name: "千里马", ctime: new Date() },
{ id: 4, name: "奔奔", ctime: new Date() },
],
},
methods: {
// 添加
add() {
this.list.push({ id: this.id, name: this.name, ctime: new Date() });
this.id = this.name = "";
},
// 删除(根据索引)
del(index) {
// console.log(index);
this.list.splice(index, 1);
},
// 删除(根据id)
// del(id) {
// const index = this.list.findIndex((item) => {
// return item.id == id;
// });
// this.list.splice(index, 1);
// // findIndex 如果为true 返回数组下标
// },
// 查找
// 第1种
searchByName() {
let result = [];
// 循环list中的每一项,拿到这一项之后,判断名称中是否包含:关键字,如果包含,则把这一项添加到result 中
for (let i = 0; i < this.list.length; i++) {
if (this.list[i].name.indexOf(this.keyWords) != -1) {
result.push(this.list[i]);
}
}
return result;
},
// searchByName() {
// let result = [];
// // 循环list中的每一项,拿到这一项之后,判断名称中是否包含:关键字,如果包含,则把这一项添加到result 中
// for (let i = 0; i < this.list.length; i++) {
// // includes 有为true
// if (this.list[i].name.includes(this.keyWords)) {
// result.push(this.list[i]);
// }
// }
// return result;
// },
// 第2种(高阶函数)
// searchByName() {
// const newArr = this.list.filter((item) => {
// // return item.name.indexOf(this.keyWords) != -1;
// return item.name.includes(this.keyWords);
// });
// return newArr;
// },
// searchByName() {
// return this.list.filter((item) => {
// // return item.name.indexOf(this.keyWords) != -1;
// return item.name.includes(this.keyWords);
// });
// },
},
});
</script>全局过滤器,处理时间
npm i moment -s边栏推荐
- 金仓数据库 KingbaseES 异构数据库移植指南 (4. 应用迁移流程)
- Injection attack
- When adding RTSP devices to easycvr platform, what is the reason for the phenomenon that they are all connected by TCP?
- adb shell ls /system/bin(索引表)
- 说透缓存一致性与内存屏障
- Pytorch multiplication and broadcasting mechanism
- (manual) [sqli labs38, 39] stack injection, error echo, character / number type
- 【防抖与节流】
- 2022-07-19 网工进阶(二十)BGP-路由优选、路由优选逐条分析
- Unity fairygui play video (Lua)
猜你喜欢

Babbitt | metauniverse daily must read: Tencent News suspended the sales service of digital collections, users left messages asking for a "refund", and phantom core also fell into the dilemma of "unsa

RK3399平台入门到精通系列讲解(导读篇)21天学习挑战介绍

如何监控NVIDIA Jetson的的运行状态和使用情况

Management of user organization structure
![[dataset display annotation] VOC file structure + dataset annotation visualization + code implementation](/img/09/645ce4de40d18d8dd4532554826c9a.png)
[dataset display annotation] VOC file structure + dataset annotation visualization + code implementation

Scrollintoview realizes simple anchor location (example: select city list)

Anfulai embedded weekly report no. 275: 2022.07.18--2022.07.24

面了个腾讯拿38K跳槽出来的,见识到了真正的测试天花板

access control

A new UI testing method: visual perception test
随机推荐
征服所有程序员的3件IT装备 →
金仓数据库 KingbaseES 异构数据库移植指南 (4. 应用迁移流程)
用户和权限创建普通用户
Apple Mobile Bluetooth networking
A new UI testing method: visual perception test
leetcode:1498. 满足条件的子序列数目【排序 + 二分 + 幂次哈希表】
js中数组与字符串常用方法属性总结
MySQL basic queries and operators
Arduino开发(二)_基于Arduino UNO开发板的RGB灯光控制方法
浅析即时通讯移动端 IM 开发中登录请求的优化
Knowledge dry goods: basic storage service novice Experience Camp
IM即时通讯开发如何提升移动网络下图片传输速度和成功率
2022-07-19 网工进阶(二十)BGP-路由优选、路由优选逐条分析
Huiding Technology: the acquisition of NXP vas business has been completed
【分层强化学习】HAC论文及代码
Preprocessing and macro definition
2022.07.11
Users and permissions restrict users from using resources
IE11 下载doc pdf等文件的方法
说透缓存一致性与内存屏障