<template>
  <div class="error-component">
    <div class="icon icon--500"
         v-if="errType===500||errType===404">
    </div>
    <div class="mt82 text">
      <slot>
        <p>
          {{text}}
        </p>
      </slot>
    </div>
    <div v-if="refresh"
         class="btn btn--refresh"
         @click="tapRefresh">刷新试试</div>
  </div>
</template>

<script>
export default {
  name: 'ErrorComponent',
  props: {
    errType: {
      type: Number,
      default: 500
    },
    text: {
      type: String,
      default: ''
    },
    refresh: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      // 网络断开的时候，请求base64位图片
      onerror: 'this.src="' + sessionStorage.getItem('PRE_IMG_ERR') + '"'
    };
  },
  methods: {
    tapRefresh() {
      window.location.reload(true);
    }
  }
};
</script>
