当前位置:网站首页>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边栏推荐
- R语言使用lm函数构建多元回归模型(Multiple Linear Regression)、并根据模型系数写出回归方程、使用deviance函数计算出模型的残差平方和
- 认识传输介质通信方式
- JVS基础框架功能列表
- LabVIEW学习笔记五:按钮按下后无法返回原状
- 【深度学习】Pytorch torch.autograd 自动差分引擎
- Openresty Lua resty core use
- 程序中的地址如何转换?
- R语言dplyr包进行数据分组聚合统计变换(Aggregating transforms)、计算dataframe数据的分组加和值(sum)
- Software test interview question: if a string is known as "hello_world_yoyo", how to get a queue ["hello", "world", "yoyo"]
- 认识网络模型数据的封装和解封装
猜你喜欢

Hexagon_V65_Programmers_Reference_Manual(5)

Introduction to JVs Foundation
![Laboratory management system implemented by SSM framework +jsp [source code + database + system paper]](/img/2e/64af546c58f3dc517cdae304daa671.png)
Laboratory management system implemented by SSM framework +jsp [source code + database + system paper]

JVs privatization deployment start failure handling scheme

UE5使用DLSS(超级采样)提升场景的 FPS 远离卡顿的优化方案

程序中的地址如何转换?

Hexagon_V65_Programmers_Reference_Manual(6)

The variable "lattice" or class "lattice.latticeeasy" (matlab) is not defined
RK3399平台开发系列讲解(进程篇)15.36、理解进程和协程

SQL coding bug
随机推荐
好开不贵,舒适安全!深度体验比亚迪宋Pro DM-i
How to translate the address in the program?
MySQL basic queries and operators
R语言使用epiDisplay包的lroc函数可视化logistic回归模型的ROC曲线并输出诊断表(diagnostic table)、可视化多条ROC曲线、使用legend函数为可视化图像添加图例
Onion group joined hands with oceanbase to realize distributed upgrading, and global data has achieved cross cloud integration for the first time
Hexagon_V65_Programmers_Reference_Manual(7)
How to calculate the execution time in the function resource usage when using the timer trigger type to process database data?
力扣解法汇总592-分数加减运算
MySQL design optimization generates columns
用户和权限限制用户使用资源
NPDP|什么样的产品经理可以被称为优秀?
[dataset display annotation] VOC file structure + dataset annotation visualization + code implementation
UE5使用DLSS(超级采样)提升场景的 FPS 远离卡顿的优化方案
Programmer growth Chapter 18: project launch
从0开始写bootloader
重复的DNA序列[hash判定重复+滑动窗口+二进制编码之位运算]
用户登录切换案例
SQL coding bug
金仓数据库 KingbaseES异构数据库移植指南 (3. KingbaseES移植能力支撑体系)
JVs official account login configuration