In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to write the code for WeChat Mini Programs to achieve calculator function". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The specific code is as follows:
Wxml
Backspace clear screen ❤ + 9 87-6 54 * 3 21 / 0. History =
Wxss
Input {width: 95%; height: 250rpx; margin: 0 auto; margin-bottom: 20rpx; border-bottom: 1rpx solid # ccc;}. Box {display: flex;} button {width: 20%; height: 150rpx; margin-bottom: 20rpx; line-height: 150rpx; background-color:rgb (0150250); color: white;}. Yellow-color {background-color:rgb (247,142,24)}
JS
/ / index.js// gets the application instance const app = getApp () Page ({data: {calculation: ", result:0, character: [], / / operational symbol operand: [], / / numeric temp:false}, / / input box input data add:function (e) {let input = e.currentTarget.dataset.text.var that = this If (input = = "+" | | input = = "-" | | input = "*" | input = = "/") {this.data.temp = false; / / is used to record whether the operator var item = "character [" + this.data.character.length+ "]"; this.setData ({[item]: input})} else {var item = "operand [" + this.data.operand.length+ "]" If (that.data.temp) {/ / get the previous value var res = "operand [" + (this.data.operand.length-1) + "]" var ress= that.data.operand.length-1; var xyz = that.data.operand [ress] * 10 + parseInt (input) That.setData ({[res]: xyz})} else {input = parseInt (input); that.data.temp = true That.setData ({[item]: input})} / / put all the content in the display box this.setData ({calculation:this.data.calculation+input})}, / / calculate the answer res:function () {console.log (this.data.character.length) Console.log (this.data.operand.length) var character_len = this.data.character.length; var operand_len = this.data.operand.length; console.log (operand_len-character_len) if (operand_len-character_len = = 1) {this.data.result = this.data.operand [0]; console.log ("initial value" + this.data.result); for (var item0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.