add error boundary

This commit is contained in:
YuukanOO 2021-01-22 09:15:22 +01:00
parent 757682c807
commit 8d58ff3590
4 changed files with 27 additions and 1 deletions

View File

@ -14,7 +14,9 @@
<!-- </div> -->
</tabs>
<card firstname="john" lastname="doe" />
<error-boundary>
<card firstname="john" lastname="doe" />
</error-boundary>
<greet />
<counter :initialValue="58" />
<a-form @custom-event="logEventTime" />
@ -59,6 +61,7 @@
<script>
import Card from "./components/Card";
import ErrorBoundary from "./components/ErrorBoundary";
import Panel from "./components/Panel";
import Tabs from "./components/Tabs";
import TabItem from "./components/TabItem";
@ -71,6 +74,7 @@ export default {
components: {
// MyCard: Card,
CustomTable,
ErrorBoundary,
Tabs,
TabItem,
Panel,

View File

@ -35,6 +35,7 @@ export default {
// console.log("Prénom", this.firstname, "Nom", this.lastname);
// this.firstname = this.$route.params.firstname;
// this.lastname = this.$route.params.lastname;
// throw new Error("oops!");
},
};
</script>

View File

@ -0,0 +1,18 @@
<template>
<div class="boundary">
<slot v-if="err === null"></slot>
<p v-else>Une erreur est survenue, veuillez recharger la page !</p>
</div>
</template>
<script>
export default {
data() {
return { err: null };
},
errorCaptured(err) {
this.err = err;
return false;
},
};
</script>

View File

@ -166,6 +166,9 @@ Vue.use({
},
});
Vue.config.errorHandler = (err, vm) =>
console.log("erreur", err, "dans le composant", vm);
new Vue({
store,
router,