[Vue] filters

suhanLee·2022년 6월 19일
0

vue-basic

목록 보기
1/29
<template>
  <div>
    <div>{{price | priceFilter}}</div>
    <div>{{day | dayFilter}}</div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      price:3000,
      day:20220101
    }
  },
  filters:{
    //priceWidthDelimiter
    priceFilter:(value)=>value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","),
    dayFilter:function(value){
      return value.toString().replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3');
    }
  }

}
</script>

filter 여러 개 연결하기

<div>{{ value | filterA | filterB }}</div>

0개의 댓글