add not found

This commit is contained in:
liangping 2022-05-13 15:32:36 +08:00
parent 9ebbd12714
commit b3d780f4ed

View File

@ -1,6 +1,18 @@
<template> <template>
<div> <div>
<b-alert
:show="error !== null"
variant="danger"
>
<h4 class="alert-heading">
Error:
</h4>
<div class="alert-body">
<span>Tx not found on chain. {{ error }}</span>
</div>
</b-alert>
<b-card <b-card
v-if="error===null"
title="Basic" title="Basic"
class="text-truncate" class="text-truncate"
> >
@ -92,13 +104,14 @@
<script> <script>
import { import {
BCard, BTableSimple, BTr, BTd, BBadge, BCardBody, BCard, BTableSimple, BTr, BTd, BBadge, BCardBody, BAlert,
} from 'bootstrap-vue' } from 'bootstrap-vue'
import { toDay, tokenFormatter } from '@/libs/utils' import { toDay, tokenFormatter } from '@/libs/utils'
import ObjectFieldComponent from './ObjectFieldComponent.vue' import ObjectFieldComponent from './ObjectFieldComponent.vue'
export default { export default {
components: { components: {
BAlert,
BCard, BCard,
BCardBody, BCardBody,
BTableSimple, BTableSimple,
@ -109,14 +122,18 @@ export default {
}, },
data() { data() {
return { return {
error: null,
tx: { tx: {} }, tx: { tx: {} },
} }
}, },
beforeRouteUpdate(to, from, next) { beforeRouteUpdate(to, from, next) {
const { hash } = to.params const { hash } = to.params
if (hash !== from.params.hash) { if (hash !== from.params.hash) {
this.error = null
this.$http.getTxs(hash).then(res => { this.$http.getTxs(hash).then(res => {
this.tx = res this.tx = res
}).catch(err => {
this.error = err
}) })
next() next()
} }
@ -124,7 +141,10 @@ export default {
created() { created() {
const { hash } = this.$route.params const { hash } = this.$route.params
this.$http.getTxs(hash).then(res => { this.$http.getTxs(hash).then(res => {
this.error = null
this.tx = res this.tx = res
}).catch(err => {
this.error = err
}) })
}, },
methods: { methods: {