blog

カスタム電卓のVue実装

シンプルなコンピュータのVue実装...

Jul 28, 2020 · 2 min. read
シェア

シンプルなコンピュータのVue実装

  1. html
<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Vueカスタム電卓の実装</title>
 <!-- Cssスタイルコードの紹介-->
 <link rel=stylesheet href="./d-1.css">
</head>
<body>
 <div id="app">
 <div id="app1">
 <input type="number" v-model.number="num1" />
 <select name="" id="" v-model.number="operator">
 <option value="0">+</option>
 <option value="1">-</option>
 <option value="2">*</option>
 <option value="3">/</option>
 </select>
 <input type="number" v-model.number="num2" />
 <button @click="cal">=</button>
 <strong>{{res}}</strong>
 </div>
 </div>
 <!-- ネットワークが必要-->
 <script src="https://..////..js"></>
 <!-- jsコードを紹介する-->
 <script src="./d-1.js"></script>
</body>
</html>
  1. ジャバスクリプト

const vm = new Vue({
 el: "#app",
 data() {
 return {
 num1: 0,
 num2: 0,
 operator: 0,
 res: 0
 }
 },
 methods: {
 cal() {
 switch (this.operator) {
 case 0:
 this.res = this.num1 + this.num2;
 break;
 case 1:
 this.res = this.num1 - this.num2;
 break;
 case 2:
 this.res = this.num1 * this.num2;
 break;
 case 3:
 this.res = this.num1 / this.num2;
 break;
 }
 }
 }
});
  1. css

#app{
 width: 100%;
 height: 80%;
 background-color: skyblue;
 position: absolute;
}
#app1{
 position: relative;
 top: 5%;
 left: 30%;
}
Read next

一般的な時間フォーマットの方法

自分で使うための時間フォーマット法、小さな機能のためにパッケージファイルを導入するのは好きではありません。

Jul 27, 2020 · 2 min read

URL入門

Jul 27, 2020 · 2 min read

APP-JSブリッジの簡単な分析

Jul 25, 2020 · 1 min read

OpenJDKとJDKの違い

Jul 24, 2020 · 2 min read