当前位置:网站首页>Brand list cases
Brand list cases
2022-07-27 20:56:00 【Yuzhibo Linzhong Road】
Add delete check 、 filter
The first 1 Step :
npm init -y
Generate .json file 
The first 2 Step :
npm i bootstrap -S
Generate 2 File 
<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=" add to "
class="btn btn-primary"
@click="add"
/>
<label> Search by brand name ::</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> operation </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>
<!-- Avoid using unary operators as attribute names delete -->
<!-- Transmission index -->
<a href="http://www.baidu.com" @click.prevent="del(index)"
> Delete </a
>
<!-- Pass on id -->
<!-- <a href="http://www.baidu.com" @click.prevent="del(item.id)"
> Delete </a
> -->
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
<script>
const app = new Vue({
el: "#app",
data: {
id: "",
name: "",
keyWords: "",
list: [
{ id: 1, name: " Mercedes ", ctime: new Date() },
{ id: 2, name: " BMW ", ctime: new Date() },
{ id: 3, name: " Swift horse ", ctime: new Date() },
{ id: 4, name: " Run ", ctime: new Date() },
],
},
methods: {
// add to
add() {
this.list.push({ id: this.id, name: this.name, ctime: new Date() });
this.id = this.name = "";
},
// Delete ( Index based )
del(index) {
// console.log(index);
this.list.splice(index, 1);
},
// Delete ( according to id)
// del(id) {
// const index = this.list.findIndex((item) => {
// return item.id == id;
// });
// this.list.splice(index, 1);
// // findIndex If true Returns an array index
// },
// lookup
// The first 1 Kind of
searchByName() {
let result = [];
// loop list Every one of them , After getting this item , Judge whether the name contains : keyword , If you include , Add this item to result in
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 = [];
// // loop list Every one of them , After getting this item , Judge whether the name contains : keyword , If you include , Add this item to result in
// for (let i = 0; i < this.list.length; i++) {
// // includes promising true
// if (this.list[i].name.includes(this.keyWords)) {
// result.push(this.list[i]);
// }
// }
// return result;
// },
// The first 2 Kind of ( Higher order function )
// 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>Global filter , The processing time
npm i moment -s边栏推荐
- [deep learning] pytoch torch Autograd automatic differential engine
- How to translate the address in the program?
- Tencent jumped out with 38K and saw the real test ceiling
- 一文了解Pycharm快捷键
- 关于栈迁移的那些事儿
- [program life] "stage summary" - unwilling to be ordinary
- R语言使用epiDisplay包的power.for.2p函数进行效用分析 ( 效能分析、Power analysis)、给定两个样本的比例值(proportions)、样本量计算效用值
- 用户和权限撤销用户权限
- How to solve the problem of missing alarm information and synchronization when Haikang equipment is connected to easycvr?
- 未定义变量 “Lattice“ 或类 “Lattice.latticeEasy“(Matlab)
猜你喜欢

Arduino development (II)_ RGB light control method based on Arduino uno development board

go --- air自动重新编译

How to translate the address in the program?
![[efficiency] abandon notepad++, this open source substitute is more awesome!](/img/41/495bbe4d1e6d953ba5c4d8984f81e7.jpg)
[efficiency] abandon notepad++, this open source substitute is more awesome!

人脸识别5.1- insightface人脸检测模型训练实战笔记

sql编码bug

Why does Alibaba prohibit more than three forms from joining?

Hexagon_V65_Programmers_Reference_Manual(6)

Best practices for Oracle kingbasees migration of Jincang database (4. Oracle database migration practice)

Jetpack compose performance optimization guide - compilation metrics
随机推荐
品牌列表案例
IPv4/IPv6、DHCP、网关、路由
Hexagon_V65_Programmers_Reference_Manual(6)
IOU 目标跟踪其二:VIOU Tracker
Advanced SQL skills CTE and recursive query
openresty lua-resty-core 使用
【深度学习】Pytorch torch.autograd 自动差分引擎
The variable "lattice" or class "lattice.latticeeasy" (matlab) is not defined
How to monitor the running status and usage of NVIDIA Jetson
Things about stack migration
从0开始写bootloader
Academic sharing | Tsinghua University, Kang Chongqing: power system carbon measurement technology and application (matlab code implementation)
[Numpy] 广播机制(Broadcast)
User and authority modify user password
Where is the program?
Go --- automatic recompilation of air
征服所有程序员的3件IT装备 →
Software test interview question: how to output "0001" when a number is known to be 1
认识传输介质网络通信的介质
[Numpy] 数组索引和切片