<template>
  <div class="address-item">
    <div  class="title">
      <div class="address-item-title">{{title}}</div>
      <div class="address-item-distance" v-if="!isKM">{{distance.toFixed(1)}}米</div>
      <div class="address-item-distance" v-else >{{(distance/1000).toFixed(1)}}千米</div>
    </div>
    <div class="address-item-address">{{address}}</div>
  </div>
</template>

<script>
export default {
  props: {
    title: String,
    address: String,
    distance:Number
  },
  computed: {
    isKM(){
      let isKM = true // 是否为千米
      if(String(this.distance).split('.')[0].length<4){
        isKM = false
      }
      return isKM
    }
  }
}
</script>

<style lang="scss">
@import "./address-item.scss";
</style>