<template>
  <div class="cus-fallback" @click="bind(callback)">
    <co-button class="xs-icon-back"><slot></slot></co-button>
  </div>
</template>

<script type="es6">
  export default {
    name: 'cus-fallback',
    props: ['callback'],
    methods: {
      bind(callback) {
        let go = this.fallback;
        // If Exists Callback Abort The Router Action And Excute The Callback
        typeof callback === 'function' ? this.callback(go) : go();
      },
      fallback() {
        let $router = this.$router;
        !$router.home || $router.home.path === $router.currentRoute.path ? corNative.closeWindow() : $router.go(-1);
      }
    }
  };
</script>

<style lang="less">
  .cus-fallback {
    display: inline-block;
    min-width: 2.2rem;

    button.mint-button {
      min-width: 1.2rem;
    }

    .xs-icon-back{
      &:before{
        font-size: @font-size-large;
      }
    }
  }
</style>
