day77 作业
一、完成todolist案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>todolist</title>
<script src="/vue/vue.js"></script>
<style type="text/css">
.list_con{
width:600px;
margin:50px auto 0;
}
.inputtxt{
width:550px;
height:30px;
border:1px solid #ccc;
padding:0px;
text-indent:10px;
}
.inputbtn{
width:40px;
height:32px;
padding:0px;
border:1px solid #ccc;
}
.list{
margin:0;
padding:0;
list-style:none;
margin-top:20px;
}
.list li{
height:40px;
line-height:40px;
border-bottom:1px solid #ccc;
}
.list li span{
float:left;
}
.list li a{
float:right;
text-decoration:none;
margin:0 10px;
}
.jishu{
background-color: blue;
}
.oushu{
background-color: orange;
}
</style>
</head>
<body>
<div class="list_con">
<h2>To do list</h2>
<input type="text" v-model="msg" id="txt1" class="inputtxt">
<input type="button" @click="add" value="增加" id="btn1" class="inputbtn">
<ul id="list" class="list">
<!-- <!– javascript:; # 阻止a标签跳转 –>-->
<!-- <li>-->
<!-- <span>学习html</span>-->
<!-- <a href="javascript:;" class="up"> ↑ </a>-->
<!-- <a href="javascript:;" class="down"> ↓ </a>-->
<!-- <a href="javascript:;" class="del">删除</a>-->
<!-- </li>-->
<!-- <li><span>学习css</span><a href="javascript:;" class="up"> ↑ </a><a href="javascript:;" class="down"> ↓ </a><a href="javascript:;" class="del">删除</a></li>-->
<!-- <li><span>学习javascript</span><a href="javascript:;" class="up"> ↑ </a><a href="javascript:;" class="down"> ↓ </a><a href="javascript:;" class="del">删除</a></li>-->
<li v-for="li,index in li_list" :class="index%2==0?'jishu':'oushu'">
<span>{{li}}</span>
<a @click="up(index)" >↑</a>
<a @click="down(index)">↓</a>
<a @click="del(index)">删除</a>
</li>
</ul>
</div>
<script>
let vm = new Vue({
el:'.list_con',
data:{
msg:'',
li_list : ['学习html','学习css','学习python']
},
methods:{
add(){
if(this.msg==""){
return false;
}
this.li_list.push(this.msg);
this.msg='';
},
up(index){
if(index==0){
return false;
}
// 这里删除得到的是一个数组,因为可能删除多个
let message = this.li_list.splice(index,1)
this.li_list.splice(index-1,0,message[0])
},
down(index){
if(index==this.li_list.length){
return false;
}
let message = this.li_list.splice(index,1)
this.li_list.splice(index+1,0,message[0])
},
del(index){
this.li_list.splice(index,1)
}
}
})
</script>
</body>
</html>
二、商品页面
完成商品的增删改,取消添加或修改的话原本input框里的值也要清除
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="/vue/vue.js"></script>
</head>
<style>
.box{
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
background-color:lightblue;
width: 400px;
height: 320px;
padding: 40px 80px;
}
.display{
display: none;
}
</style>
<body>
<div id="app">
<table class="table table-hover">
<thead>
<tr>
<th>id</th>
<th>名称</th>
<th>数量</th>
<th>价格</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="good,ind in goods_list">
<td>{{ind+1}}</td>
<td>{{good.name}}</td>
<td>{{good.price}}</td>
<td>{{good.count}}</td>
<td><button class="btn btn-success" @click="type=false,index=ind">编辑</button>
<button class="btn btn-danger" @click="del(index)">删除</button></td>
</tr>
</tbody>
</table>
<button class="btn btn-info" @click="type=false">添加商品</button>
<div :class="{box:true,display:type}">
商品标题: <input type="text" v-model="name"><br><br>
商品价格: <input type="text" v-model="price"><br><br>
商品数量: <input type="text" v-model="count"><br><br>
<button @click="add">保存</button>
<button @click="clear(),type=true">取消</button>
</div>
</div>
<script>
let vm = new Vue({
el:'#app',
data:{
type:true,
index:'',
name:'',
price:'',
count:'',
goods_list:[
{'name':'python入门','price':20,'count':10},
{'name':'python进阶','price':22,'count':33},
{'name':'python入土','price':123123,'count':1213},
]
},
methods:{
del(index){
this.goods_list.splice(index,1)
},
add(){
console.log(this.index)
if(this.index == ''){
// 如果index是空则是追加,非空为修改
this.goods_list.push({'name':this.name,'price':this.price,'count':this.count})
}else {
this.goods_list.splice(this.index,1)
this.goods_list.splice(this.index,0,{'name':this.name,'price':this.price,'count':this.count})
}
this.index=''
this.name=''
this.price=''
this.count=''
console.log(this.index)
},
clear(){
console.log(123)
this.index=''
this.name=''
this.price=''
this.count=''
}
}
})
</script>
</body>
</html>
day77 作业的更多相关文章
- python10作业思路及源码:类Fabric主机管理程序开发(仅供参考)
类Fabric主机管理程序开发 一,作业要求 1, 运行程序列出主机组或者主机列表(已完成) 2,选择指定主机或主机组(已完成) 3,选择主机或主机组传送文件(上传/下载)(已完成) 4,充分使用多线 ...
- SQLServer2005创建定时作业任务
SQLServer定时作业任务:即数据库自动按照定时执行的作业任务,具有周期性不需要人工干预的特点 创建步骤:(使用最高权限的账户登录--sa) 一.启动SQL Server代理(SQL Server ...
- 使用T-SQL找出执行时间过长的作业
有些时候,有些作业遇到问题执行时间过长,因此我写了一个脚本可以根据历史记录,找出执行时间过长的作业,在监控中就可以及时发现这些作业并尽早解决,代码如下: SELECT sj.name , ...
- T-SQL检查停止的复制作业代理,并启动
有时候搭建的复制在作业比较多的时候,会因为某些情况导致代理停止或出错,如果分发代理时间停止稍微过长可能导致复制延期,从而需要从新初始化复制,带来问题.因此我写了一个脚本定期检查处于停止状态的分 ...
- Python09作业思路及源码:高级FTP服务器开发(仅供参考)
高级FTP服务器开发 一,作业要求 高级FTP服务器开发 用户加密认证(完成) 多用户同时登陆(完成) 每个用户有不同家目录且只能访问自己的家目录(完成) 对用户进行磁盘配额,不同用户配额可不同(完成 ...
- 个人作业week3——代码复审
1. 软件工程师的成长 感想 看了这么多博客,收获颇丰.一方面是对大牛们的计算机之路有了一定的了解,另一方面还是态度最重要,或者说用不用功最重要.这些博客里好些都是九几年或者零几年就开始学习编 ...
- 个人作业-week2:关于微软必应词典的案例分析
第一部分 调研,评测 评测基于微软必应词典Android5.2.2客户端,手机型号为MI NOTE LTE,Android版本为6.0.1. 软件bug:关于这方面,其实有一些疑问.因为相对于市面上其 ...
- 软件工程第二次作业——git的使用
1. 参照 http://www.cnblogs.com/xinz/p/3803109.html 的第一题,每人建立一个GitHub账号,组长建立一个Project,将本组成员纳入此Porject中的 ...
- hadoop作业调度策略
一个Mapreduce作业是通过JobClient向master的JobTasker提交的(JobTasker一直在等待JobClient通过RPC协议提交作业),JobTasker接到JobClie ...
随机推荐
- 制作zipkin docker镜像
这里使用的zipkin知识基于内存的版本,没有接入外部存储 https://zipkin.io/ https://github.com/openzipkin/zipkin https://github ...
- 实验三 Linux系统用户管理及VIM配置
项目 内容 这个作业属于哪个课程 班级课程的主页链接 这个作业的要求在哪里 作业要求链接接地址 学号-姓名 17041428-朱槐健 作业学习目标 1.学习Linux系统用户管理 2.学习vim使用 ...
- Nlog打印日志到Influxdb数据库
1.安装和使用Influxdb 安装部分网上资料比较多,也讲的比较详细,请自行百度. 下面大概讲下InfluxDB的写入和读取数据的方法. 我使用了InfluxData.Net包. 工具->Nu ...
- tp5的 LayUI分页样式实现
1.先配置你的分页参数: //分页配置 'paginate' => [ 'type' => 'Layui', 'var_page' => 'page', 'li ...
- CentOS 7设置静态IP并修改DNS
1. 设置静态IP 首先需要确定网线插在服务器的哪一个网络接口上,接口旁边一般都有写.我这边是插在1号接口上的. 然后修改网络配置文件,文件位于 /etc/sysconfig/network-scri ...
- (十)自动化测试pom完整文件
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...
- c常用函数-strcpy和strncpy
strcpy和strncpy strcpy在脚本开发中经常用到,例如处理参数等,它的作用是把一个字符串复制到另一个字符串中. strncpy的作用是把一个字符串中的指定长度复制到另一个字符串中,如果指 ...
- 税务ukey如何批量开票
最近税局开始大力推税务ukey版本,不过目前接口还未开放,就连航信,百旺否还没有对应接口,所以自己研究了下,在之前税控基础上,谁知道搞定了,通过安装插件可以批量开票,包括纸质,电子发票ofd格式. 联 ...
- GetLastError返回值含义
GetLastError的返回值的含义: (0)-操作成功完成. (1)-功能错误. (2)- 系统找不到指定的文件. (3)-系统找不到指定的路径. (4)-系统无法打开文件. (5)-拒绝访问. ...
- c++_primer_第4版目录
https://vdisk.weibo.com/s/BN_NALmbbBH01 第1章 快速入门1.1 编写简单的C++程序1.2 初窥输入/输出1.2.1 标准输入与输出对象1.2.2 一个使用IO ...