https://vuejs.org/examples/#temperature-converter > Vue_JS 뷰

Vue_JS 뷰

Examples https://vuejs.org/examples/#temperature-converter

페이지 정보

본문

https://vuejs.org/examples/#temperature-converter


-------------------------------


<!--

https://eugenkiss.github.io/7guis/tasks/#temp

-->


<script>

export default {

  data() {

    return {

      c: 0,

      f: 32

    }

  },

  methods: {

    setC(e, c = +e.target.value) {

      this.c = c

      this.f = c * (9 / 5) + 32

    },

    setF(e, f = +e.target.value) {

      this.f = f

      this.c = (f - 32) * (5 / 9)

    }

  }

}

</script>


<template>

  <input type="number" :value="c" @change="setC"> Celsius =

  <input type="number" :value="f" @change="setF"> Fahrenheit

</template>