add error boundary
This commit is contained in:
parent
757682c807
commit
8d58ff3590
@ -14,7 +14,9 @@
|
|||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
</tabs>
|
</tabs>
|
||||||
|
|
||||||
|
<error-boundary>
|
||||||
<card firstname="john" lastname="doe" />
|
<card firstname="john" lastname="doe" />
|
||||||
|
</error-boundary>
|
||||||
<greet />
|
<greet />
|
||||||
<counter :initialValue="58" />
|
<counter :initialValue="58" />
|
||||||
<a-form @custom-event="logEventTime" />
|
<a-form @custom-event="logEventTime" />
|
||||||
@ -59,6 +61,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Card from "./components/Card";
|
import Card from "./components/Card";
|
||||||
|
import ErrorBoundary from "./components/ErrorBoundary";
|
||||||
import Panel from "./components/Panel";
|
import Panel from "./components/Panel";
|
||||||
import Tabs from "./components/Tabs";
|
import Tabs from "./components/Tabs";
|
||||||
import TabItem from "./components/TabItem";
|
import TabItem from "./components/TabItem";
|
||||||
@ -71,6 +74,7 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
// MyCard: Card,
|
// MyCard: Card,
|
||||||
CustomTable,
|
CustomTable,
|
||||||
|
ErrorBoundary,
|
||||||
Tabs,
|
Tabs,
|
||||||
TabItem,
|
TabItem,
|
||||||
Panel,
|
Panel,
|
||||||
|
|||||||
@ -35,6 +35,7 @@ export default {
|
|||||||
// console.log("Prénom", this.firstname, "Nom", this.lastname);
|
// console.log("Prénom", this.firstname, "Nom", this.lastname);
|
||||||
// this.firstname = this.$route.params.firstname;
|
// this.firstname = this.$route.params.firstname;
|
||||||
// this.lastname = this.$route.params.lastname;
|
// this.lastname = this.$route.params.lastname;
|
||||||
|
// throw new Error("oops!");
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
18
vue2/src/components/ErrorBoundary.vue
Normal file
18
vue2/src/components/ErrorBoundary.vue
Normal 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>
|
||||||
@ -166,6 +166,9 @@ Vue.use({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Vue.config.errorHandler = (err, vm) =>
|
||||||
|
console.log("erreur", err, "dans le composant", vm);
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
store,
|
store,
|
||||||
router,
|
router,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user