Skip to content

Commit e60d6ac

Browse files
committed
docs: document how to use errors
1 parent da12ca0 commit e60d6ac

File tree

3 files changed

+13
-29
lines changed

3 files changed

+13
-29
lines changed

README.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The simplest way to render components is as a VueJs template:
1414

1515
```vue
1616
<template>
17-
<VueLive :code="`<date-picker />`" :components="{ DatePicker }">
17+
<VueLive :code="`<date-picker />`" :components="{ DatePicker }" @error="(e) => handleError(e)">
1818
</template>
1919
2020
<script>
@@ -35,34 +35,6 @@ export default {
3535

3636
Check out the [demo](http://vue-live.surge.sh) for alternative syntaxes to write your showcases.
3737

38-
## Configuration
39-
40-
```js
41-
module.exports = {
42-
// ...
43-
plugins: [
44-
[
45-
'live',
46-
{
47-
// to use a custom layout for your vue components
48-
layout: path.resolve(__dirname, "../custom-layout")
49-
}
50-
],
51-
[
52-
"@vuepress/register-components",
53-
{
54-
components: [
55-
{
56-
name: "vue-slider",
57-
path: path.resolve(__dirname, "../vue-slider")
58-
}
59-
]
60-
}
61-
]
62-
]
63-
}
64-
```
65-
6638
## How to contribute
6739

6840
```sh

src/Preview.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ export default {
9797
});
9898
},
9999
handleError(e) {
100+
/**
101+
* Emitted every time the component rendered throws an error
102+
* Catches runtime and compilation errors
103+
* @event
104+
* @property { Error } - the error thrown
105+
*/
100106
this.$emit("error", e);
101107
if (e.constructor === VueLiveParseTemplateError) {
102108
e.message = `Cannot parse template expression: ${e.expression}\n\n${e.message}`;

src/VueLive.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
/>
2020
</template>
2121
<template v-slot:preview>
22+
<!--
23+
* Emitted every time the component rendered throws an error
24+
* Catches runtime and compilation errors
25+
* @event error
26+
* @property { Error } - the error thrown
27+
-->
2228
<Preview
2329
:key="codeKey"
2430
:code="model"

0 commit comments

Comments
 (0)