vue 应用 : 计数器组件
2024-09-07 18:30:17
<template>
<div class="input-number">
<div @click="sub" :class="(islight ? 'light' : '') + ' sub'">-</div>
<div class="num">{{ ipt }}</div>
<div class="add" @click="add">+</div>
</div>
</template> <script>
export default {
name: 'CRInputnumber',
componentName: 'CRInputnumber', data() {
return {
ipt:1,
islight: true,
}
},
created() {
if (this.count > 0) {
this.ipt = this.count
}
this.islight = this.lightFunc()
},
props: {
count:{
type: Number,
default: 1
},
},
methods: {
// 减少数量
sub: function () {
if (this.ipt < 2) {
return
}
this.ipt--
this.islight = this.lightFunc()
},
// 增加数量
add: function () {
this.ipt++
this.islight = this.lightFunc()
},
lightFunc(){
if (this.ipt < 2) {
return true
} else {
return false
}
}
} }
</script> <style lang="LESS" scoped>
@fs12:3.2vw;
@fs14:3.733vw;
@fs15:4vw;
@fs16:4.267vw;
@fs17:4.533vw;
@fs20:5.333vw;
@fs22:5.867vw; @pd1:2.666vw;
@pd2:3.333vw;
@bw:100vw;
@bh:23.333vw;
@iw:16.666vw;
@black:#4c4948;
@gray:#bfc0c0; body,p,h1,h2,h3,h4,h5,h6,img{
padding: 0;
margin:0;
border:0;
}
div,span,p{
font-size: @fs12;
}
.input-number{
color: @black;
font-size: @fs20; min-width: 4.5625rem;
height: 1.375rem;
box-sizing: border-box;
border: 1px solid #e5e5e5;
position: relative;
margin-top: -0.6875rem;
top:50%;
display: flex;
justify-content: space-between;
.sub,.add,.num{
height: 100%;
line-height: 1.25rem;
text-align: center;
}
.sub,.add{
width: 1.375rem;
transform: scale(1.5,1.5) translateY(-0.3vw);
}
.num{
border-left:1px solid #e5e5e5;
border-right:1px solid #e5e5e5;
padding: 0 0.6rem;
font-weight: 700;
} .light{
color: #e5e5e5;
}
} </style>
最新文章
- sql server 跨数据库插入数据
- oracle case when 在查询时候的用法。
- mysql管理(一)
- 点击页面div弹窗以外隐藏的两种思路
- 移动端单页视图库,适用于制作移动Web touchbox
- Logstash type来标记事件类型,通过type判断
- RESTful最佳实践之基于 jersey 的增删改查
- WPF六个控制概述
- ReentrantLock深入学习
- 【翻译】.Net Core的意义
- ##1.Centos7环境准备-- openstack pike
- [知了堂学习笔记]_牵线Eclipse和Tomcat第二篇 —— 安装Tomcat&;&;添加Tomcat到Eclipse
- zeromq的安装,部署(号称最快的消息队列,消息中间件)
- linux下read命令详解
- 同步或者重构Activiti Identify用户数据的多种方案比较
- PHP之流程控制
- Windows 环境变量立即生效
- hdu1281 棋盘游戏 二分图最大匹配
- python(十二)下:ORM框架SQLAlchemy使用学习
- excel自定义函数添加和使用方法