最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序?qū)崿F(xiàn)簡(jiǎn)單計(jì)算器與秒表

 更新時(shí)間:2022年09月08日 16:07:57   作者:楓渝浪天下  
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)簡(jiǎn)單計(jì)算器與秒表,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)簡(jiǎn)單計(jì)算器與秒表的具體代碼,供大家參考,具體內(nèi)容如下

實(shí)驗(yàn)內(nèi)容:

任務(wù)一:實(shí)現(xiàn)一個(gè)簡(jiǎn)單的加減乘除運(yùn)算。

首先輸入兩個(gè)運(yùn)算數(shù),然后選擇加、減、乘、除四個(gè)運(yùn)算中的某一個(gè)運(yùn)算按鈕(共4個(gè)按鈕),最后在界面上顯示運(yùn)算結(jié)果。運(yùn)算數(shù)及運(yùn)算結(jié)果支持整數(shù)和浮點(diǎn)數(shù)。

任務(wù)二:設(shè)計(jì)一個(gè)計(jì)數(shù)秒表。

不要求繪制秒表表盤、表針,只要求以數(shù)字的方式顯示秒表計(jì)數(shù)即可。注意:顯示形式為:分鐘:秒數(shù):百分之一秒數(shù)。(如果不清楚可以看看自己手機(jī)上的秒表數(shù)字顯示)。

界面上設(shè)計(jì)一個(gè)按鈕,計(jì)數(shù)未開始時(shí),按鈕顯示文字為“開始“,點(diǎn)擊后開始計(jì)數(shù),并且按鈕的顯示文字變成”停止“,如果再次點(diǎn)擊按鈕則計(jì)數(shù)停止。

實(shí)驗(yàn)效果:

實(shí)驗(yàn)代碼目錄:

countingWatch 目錄中放的是 秒表代碼,  index目錄中放的是 簡(jiǎn)單計(jì)算器代碼

實(shí)驗(yàn)代碼:

簡(jiǎn)單計(jì)算器代碼:

index.js

// index.js
?
const app = getApp()
?
Page({
? data: {
? ? ? describe: "計(jì)算",
? ? ? num1: null,
? ? ? num2: null,
? ? ? result: 0
? },
? ? ? input1(e) {
? ? ? this.setData({
? ? ? ? ? ? ? num1: parseFloat(e.detail.value)
? ? ? ? ? })
? },
? ? ?input2(e) {
? ? ? this.setData({
? ? ? ? ? ? ? num2: parseFloat(e.detail.value)
? ? ? ? ? })
? },
? addButton(e) {
? ? ? if (this.data.num1 && this.data.num2) {
? ? ? ? ? this.setData({
? ? ? ? ? ? describe: "加法",
? ? ? ? ? ? ? result: this.data.num1 + this.data.num2
? ? ? ? ? })
? ? ? }?
? },
? subButton(e) {
? ? ? if (this.data.num1 && this.data.num2) {
? ? ? ? ? this.setData({
? ? ? ? ? ? describe: "減法",
? ? ? ? ? ? ? result: this.data.num1 - this.data.num2
? ? ? ? ? })
? ? ? }?
?
? },
? mulButton(e) {
? ? ? if (this.data.num1 && this.data.num2) {
? ? ? ? ? this.setData({
? ? ? ? ? ? describe: "乘法",
? ? ? ? ? ? ? result: this.data.num1 * this.data.num2
? ? ? ? ? })
? ? ? }?
?
? },
? divButton(e) {
? ? ? if (this.data.num1 && this.data.num2) {
? ? ? ? ? this.setData({
? ? ? ? ? ? describe: "除法",
? ? ? ? ? ? ? result: this.data.num1 / this.data.num2
? ? ? ? ? })
? ? ? }?
? },
? jump:function(){
? ? ? wx.navigateTo({
? ? ? ? url: '../countingWatch/countingWatch'
? ? ? })
? }
?
})

index.wxml

<!--index.wxml-->
?
<view class="firstNum">
? ? <!-- <text>請(qǐng)輸入第一個(gè)運(yùn)算數(shù):</text> -->
? ? <label class="text" >請(qǐng)輸入第一個(gè)運(yùn)算數(shù): </label>
? ? <input type="digit" bindinput="input1" ? ? ? style=" border: 2rpx solid #ccc; width:150px; ?margin-left: 5px; "/>
</view>
<view class="secondNum">
? ? <text class="text">請(qǐng)輸入第二個(gè)運(yùn)算數(shù):</text>
? ? <input type="digit" bindinput="input2" style=" border: 2rpx solid #ccc; width:150px; ?margin-left: 5px;"/>
</view>
<view class="describe">
? ? <button bindtap="addButton" style="width: 30rpx;">+</button>
? ? <button bindtap="subButton" style="width: 30rpx">
? ? -</button>
? ? <button bindtap="mulButton" style="width: 30rpx" ?>
? ? *</button>
? ? <button bindtap="divButton" style="width: 30rpx">
? ? /</button>
? ?
</view>
<view class="result">
? ? <text>{{describe}}結(jié)果:{{result}}</text>
</view>
<button bindtap="jump" class="jump">跳轉(zhuǎn)至秒表</button>

index.wxss

/**index.wxss**/
.text{
? font-size: 1.5ex;
? font-weight: 600;
}
.firstNum,
.secondNum,
.result {
? margin: 50rpx;
? display: flex;
? flex-direction: row;
? height:50px;
}
.describe {
? display: flex;
? justify-content: space-evenly;
}
.describe button {
? display: flex;
? align-items: center;
? justify-content: center;
? color: black;
? background-color: aqua;
}
.jump{
? background: rgb(204, 19, 221);
? margin-top: 100px;
}

秒表代碼:

countingWatch.js

// pages/countingWatch/countingWatch.js
? const app = getApp()
Page({
? data: {
? ? timer:null,
? ? minute: ?0, ? // 分
? ? second: 0 , ? // 秒
? ? millisecond:0,
? ? describe:'開始',
? ? timeformat:'00:00:00'
? },
?
//計(jì)時(shí)開始
? start: function () {
?
? ? ? if(this.data.describe == "開始"){
? ? ? ? ? this.setData({
? ? ? ? ? ? describe:"停止"
? ? ? ? ? })
? ? ? ?
? ? ? ? ? this.setData({
? ? ? ? ? ? minute:0,
? ? ? ? ? ? second:0,
? ? ? ? ? ? millisecond:0
? ? ? ? ? })
? ? ? ? ? this.data.timer = setInterval(this.counter,50)
?
? ? ? }else{
? ? ? ? this.setData({
? ? ? ? ? describe:"開始"})
? ? ? ? ? ?//這個(gè)是系統(tǒng)提供的用于時(shí)鐘暫停的方法
? ? ? ? ? clearInterval(this.data.timer)
? ? ? ? ? ?
? ? ? }
? }, ?
? ? counter:function(){
? ? ? var second = this.data.second
? ? ? var minute = this.data.minute
? ? ? var millisecond = this.data.millisecond
? ? ? ?this.setData({
? ? ? ? ?millisecond:millisecond+5
? ? ? ?})
? ? ? ?if(millisecond >=99){
? ? ? ? ? ?this.setData({
? ? ? ? ? ? millisecond:0,
? ? ? ? ? ?second:second+1
? ? ? ? ? ?})
? ? }
? ? ? ? ? ?if(second == 60){
? ? ? ? ? ? ? this.setData({
? ? ? ? ? ? ? ? second : 0,
? ? ? ? ? ? ? ? minute:minute+1
? ? ? ? ? ? ? })
? ? ? ? ? ?}
?
?
? ? ? ?this.setData({
? ? ? ? timeformat:minute+":"+second+":"+millisecond
? ? ? ?})
?
? ?
?},
? ? ?jump:function(){
? ? ? ?wx.navigateTo({
? ? ? ? ?url: '../index/index'
? ? ? ?})
? ? ?}
??
? ? })

countingWatch.wxml

<!--pages/countingWatch/countingWatch.wxml-->
?
<view class="timeformat">{{timeformat}}</view>
<button ?bindtap="start">{{describe}}</button>
<button ?class="jump" bindtap="jump">跳轉(zhuǎn)至計(jì)算器</button>

countingWatch.wxss

/* pages/countingWatch/countingWatch.wxss */
?
button{
? width:150rpx;
? background: rgb(51, 231, 15);
? color: #fff;
? margin-bottom: 8px;
}
.timeformat{
? margin: 20px;
? ?text-align: center;
? ?font-weight: 600;
? ?font-size: 30px;
}
.jump{
? background: rgb(204, 19, 221);
? margin-top: 100px;
}

還有一個(gè)用于銜接兩個(gè)頁(yè)面的代碼

app.json

?{
? "pages": [
? ? "pages/index/index",
? ? "pages/countingWatch/countingWatch",
? ? "pages/logs/logs"
? ?
? ],
? "window": {
? ? "backgroundTextStyle": "light",
? ? "navigationBarBackgroundColor": "#fff",
? ? "navigationBarTitleText": "兩個(gè)數(shù)的運(yùn)算",
? ? "navigationBarTextStyle": "black"
? },
? "style": "v2",
? "sitemapLocation": "sitemap.json"
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • JavaScript無(wú)縫滾動(dòng)效果的實(shí)例代碼

    JavaScript無(wú)縫滾動(dòng)效果的實(shí)例代碼

    本文給大家分享一段實(shí)例代碼有關(guān)js實(shí)現(xiàn)無(wú)縫滾動(dòng)效果,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下
    2017-03-03
  • JS實(shí)現(xiàn)圖片切換特效

    JS實(shí)現(xiàn)圖片切換特效

    這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)圖片切換特效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • Javascript中正則表達(dá)式的全局匹配模式分析

    Javascript中正則表達(dá)式的全局匹配模式分析

    先看一道JavaScript題目,據(jù)說(shuō)是國(guó)內(nèi)某知名互聯(lián)網(wǎng)企業(yè)的JavaScript筆試題,如果對(duì)正則的全局匹配模式不了解的話可能會(huì)對(duì)下面的輸出結(jié)果感到疑惑。
    2011-04-04
  • 關(guān)于驗(yàn)證碼在IE中不刷新的快速解決方法

    關(guān)于驗(yàn)證碼在IE中不刷新的快速解決方法

    下面小編就為大家?guī)?lái)一篇關(guān)于驗(yàn)證碼在IE中不刷新的快速解決方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-09-09
  • js實(shí)現(xiàn)的簡(jiǎn)單radio背景顏色選擇器代碼

    js實(shí)現(xiàn)的簡(jiǎn)單radio背景顏色選擇器代碼

    這篇文章主要介紹了js實(shí)現(xiàn)的簡(jiǎn)單radio背景顏色選擇器代碼,利用鼠標(biāo)事件及頁(yè)面元素動(dòng)態(tài)操作實(shí)現(xiàn)頁(yè)面背景顏色的改變功能,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-08-08
  • js module大戰(zhàn)

    js module大戰(zhàn)

    這篇文章主要介紹了js module,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • 網(wǎng)上抓的一個(gè)特效

    網(wǎng)上抓的一個(gè)特效

    網(wǎng)上抓的一個(gè)特效...
    2007-05-05
  • JS實(shí)現(xiàn)的幻燈片切換顯示效果

    JS實(shí)現(xiàn)的幻燈片切換顯示效果

    這篇文章主要介紹了JS實(shí)現(xiàn)的幻燈片切換顯示效果,涉及javascript通過(guò)擴(kuò)展實(shí)現(xiàn)針對(duì)頁(yè)面元素的動(dòng)態(tài)切換操作相關(guān)技巧,需要的朋友可以參考下
    2016-09-09
  • html a標(biāo)簽-超鏈接中confirm方法使用介紹

    html a標(biāo)簽-超鏈接中confirm方法使用介紹

    confirm可以彈出確定取消對(duì)話框,然后根據(jù)用戶的選擇執(zhí)行相應(yīng)的操作,接下來(lái)介紹實(shí)現(xiàn)過(guò)程,需要了解的朋友可以參考下
    2013-01-01
  • 解決uniapp上傳小程序體積過(guò)大的問(wèn)題

    解決uniapp上傳小程序體積過(guò)大的問(wèn)題

    在昨天的工作中遇到了一個(gè)微信小程序上傳代碼過(guò)大的情況,在這里總結(jié)一下具體的解決步驟,首先介紹一下,技術(shù)棧是使用uniapp框架+HBuilderX的開發(fā)環(huán)境,需要的朋友可以參考下
    2023-09-09

最新評(píng)論

奉新县| 怀仁县| 集贤县| 东港市| 濉溪县| 县级市| 漠河县| 桃江县| 湖州市| 西林县| 扎兰屯市| 临沧市| 宜丰县| 永新县| 新郑市| 和政县| 华容县| 芦山县| 庆城县| 桦川县| 全州县| 墨脱县| 米脂县| 宝清县| 肇州县| 新巴尔虎左旗| 金平| 辽源市| 东乌| 布尔津县| 固阳县| 永登县| 龙门县| 垣曲县| 定陶县| 勃利县| 庆阳市| 孝感市| 黔西| 漳浦县| 呼图壁县|