当前位置: 首页 > news >正文

没用的计算器

本次的项目仍然属于没用的模块,仅供娱乐,最后附有效果视频,如需要源代码可以私信或评论,本次还是使用vue来实现的,同样也可以修改为JS

一、HTML部分

        <div class="con"><div class="calculator"><input type="text" v-model="firstContent"><select v-model="option"><option v-for="item in optionList" :key="item">{{ item }}</option></select><input type="text" v-model="secondContent">=<!--由于v-if和v-show的效果都会使元素不占位置因此使用三元表达式来解决此问题--><p :class="flag?'pClass':''">{{ countThing }}</p></div><button @click="count">开始计算</button></div>

二、CSS/LESS部分

// 按钮动画
@keyframes moving {0% {transform: rotate(0deg);}100% {transform: rotate(360deg);}
}.calculatorView {.con {width: 300px;height: 100px;margin: 100px auto;box-sizing: border-box;border: 2px solid black;border-radius: 10px;text-align: center;padding-top: 20px;}// 按钮部分button {margin-top: 10px;position: relative;cursor: pointer;background: transparent;height: 40px;width: 100px;border-radius: 10px;font-size: 18px;color: #f4c24c;border: 0;overflow: hidden;&::after,&::before {content: '';position: absolute;}&::after {border-radius: 10px;width: calc(100% - 2 * 2px);height: calc(100% - 2 * 2px);left: 2px;top: 2px;background-color: white;z-index: -1;}&::before {z-index: -2;animation: moving 1s linear infinite;transform-origin: left top;left: 50%;top: 50%;width: 200%;height: 200%;background-color: #68fd72;}}// 计算的东西.calculator {display: flex;justify-content: space-between;input, select {width: 40px;height: 20px;margin: 0 10px;}.pClass {opacity: 1;}p {opacity: 0;width: 80px;}}
}

三、JS部分

export default defineComponent({name: "calculatorView",data() {return {// p是否显示flag: false,// 下拉菜单数组optionList: ['+', '-', '*', '/', '%'],// 第一个输入框的内容firstContent: '',// 第二个输入框的内容secondContent: '',// 输入框内容option: '+',// 显示出来的东西countThing: ''}},methods: {count() {if (this.firstContent !== '' && this.secondContent !== '') {this.flag = truethis.countThing = this.firstContent + this.option + this.secondContent}}}
})

四、显示效果

没用的计算器

http://www.lryc.cn/news/299439.html

相关文章:

  • 基于 Python 的大数据的电信反诈骗系统
  • 二、ClickHouse简介
  • C++ 11新特性之并发
  • jvm问题自查思路
  • 任意IOS16系统iPad/Iphone开启台前调度
  • LeetCode、452. 用最少数量的箭引爆气球【中等,贪心,区间问题】
  • 洛谷C++简单题小练习day10—umi的函数
  • 【Linux学习】线程互斥与同步
  • 前端开发:(三)CSS入门
  • 一周学会Django5 Python Web开发-Django5创建项目(用PyCharm工具)
  • 寒假学习记录13:JS对象
  • 学生成绩管理系统|基于Springboot的学生成绩管理系统设计与实现(源码+数据库+文档)
  • C#向数组指定索引位置插入新的元素值:自定义插入方法 vs List<T>.Add(T) 方法
  • 【大数据Hive】hive 表设计常用优化策略
  • jvm垃圾收集器之七种武器
  • STM32面试相关问题
  • 风行智能电视N39S、N40 强制刷机升级方法,附刷机升级数据MstarUpgrade.bin
  • 【C语言】简易英语词典
  • 【算法题】104. 二叉树的最大深度
  • Docker配置Portainer容器管理界面
  • Linux network namespace 访问外网以及多命名空间通信(经典容器组网 veth pair + bridge 模式认知)
  • 网络渗透测试:Wireshark抓取qq图片
  • 网络协议与攻击模拟_16HTTP协议
  • 叙事弧基础
  • python从入门到精通(二十):python的exe程序打包制作
  • three.js 细一万倍教程 从入门到精通(一)
  • 电路设计(16)——纪念馆游客进出自动计数显示器proteus仿真
  • Python数学建模之回归分析
  • 单片机学习笔记---DS18B20温度传感器
  • 【网络】WireShark过滤 | WireShark实现TCP三次握手和四次挥手