DBILITY

vue 실습 01 본문

front-end & ui/vuejs

vue 실습 01

DBILITY 2021. 8. 6. 17:48
반응형

dataset을 binding하고, 버튼을 눌렀을때, 가격을 반으로 처리해 보았다. 이게 맞는지는 모르겠다.

<template>
  <img alt="Vue logo" src="./assets/logo.png">
  <div v-for="(estate,index) in estateList" :key="index">
    <h4>{{estate.name}}</h4>
    <p>{{new Intl.NumberFormat('ko-KR',{style:'currency', currency:'KRW'}).format(estate.price)}}원</p>
  </div>
  <button @click="discount">반값할인</button>
</template>

<script>

export default {
  name: 'App',
  data() {
    return {
      estateList: [
        {name: '우리집', price: 50000000},
        {name: '너네집', price: 1500000000}
      ]
    }
  },
  methods : {
    discount(){
      this.estateList.forEach(function(value, index, array){
        console.log(value,index,array);
        array[index].price = value.price/2;
      });
    }
  },
  components: {}
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
반응형

'front-end & ui > vuejs' 카테고리의 다른 글

vuejs BASE_URL relative path build  (0) 2021.10.26
vue 3 image src binding  (0) 2021.08.06
vue 3 vue-router,plugin 설치 및 project 적용  (0) 2021.08.04
vue 3 version project create  (0) 2021.07.30
vue 3 instance lifecycle  (0) 2020.11.28
Comments