0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vue CLI のサンプル (整数の加算、減算)

Last updated at Posted at 2019-04-06

Vue CLI のサンプルです。次のようなページを作成します。
整数の加算、減算をします。
calc01.png

src/App.vue
<template>
  <div>
      {{value_aa}}
<input type="text" v-model="value_aa">
<p />
      {{value_bb}}
<input type="text" v-model="value_bb">
<p />{{wa}}<p />{{sa}}</p>
<button @click="calculation()">計算</button>
<button @click="clear()">クリア</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      value_aa: 0,
      value_bb: 0,
	wa: 0,
	sa: 0,
    }
  },
  methods: {
    calculation () {
      this.wa = parseInt(this.value_aa) + parseInt(this.value_bb)
      this.sa = parseInt(this.value_aa) - parseInt(this.value_bb)
    },
    clear () {
      this.value_aa = 0
      this.value_bb = 0
      this.wa = 0
      this.sa = 0
    }
  }
}
</script>

src/App.vue の使い方はこちら
Vue CLI の簡単な使い方

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?