微信自帶計算器功能在哪裏

來源:趣味經驗館 2.06W

開啟微信開發工具,新建一個項目,命名爲calculate。

新建page,輸入名稱爲calculate。

calculate目錄下自動生成4個檔案。

開啟calculate.json檔案,使其pages/calculate/calculate檔案處在第一項。

微信自帶計算器功能在哪裏

5.編寫calculate.wxml,輸入:

微信自帶計算器功能在哪裏 第2張

6.編寫calculate.wcss,輸入:.container{justify-content: flexstart;padding:30rpx0;}

container input{background-color: #eee;border-radius: 3px;text-align: left;width: 720rpx;height: 100rpx;line-height: 100rpx;margin:20rpx;}container button{width: 100%;

微信自帶計算器功能在哪裏 第3張

7.編寫calculate.js,輸入代碼:data:{num1:"",num2:"",result:""},getNum1:function(e){var n=e.detail.value;if(!isNaN(n{this.setData({num1:n});}},getNum2:function(e{var n=e.detail.value;if(!isNaN(n)){this.setData({num2:n});}},add:function(e){varn=this.data.num1*1+this.data.num2*1;this.setData({result:n});},

微信自帶計算器功能在哪裏 第4張

微信自帶計算器功能在哪裏 第5張

8.輸入完成後,儲存代碼,得到如下計算器的介面如下。

微信自帶計算器功能在哪裏 第6張

9.在輸入框中,輸入數字,並點擊確定按鈕,則得到運算結果。

微信自帶計算器功能在哪裏 第7張

以上便是針對該問題所整理出來的具體操作步驟,希望可以幫助到需要的朋友。

熱門標籤