diff --git a/src/Preview.vue b/src/Preview.vue index be56e5b..b551a37 100644 --- a/src/Preview.vue +++ b/src/Preview.vue @@ -49,6 +49,14 @@ export default { jsx: { type: Boolean, default: false + }, + /** + * Outside data to the preview + * @example { count: 1 } + */ + dataScope: { + type: Object, + default: () => {} } }, data() { @@ -109,6 +117,11 @@ export default { adaptCreateElement, concatenate ) || {}; + + if (this.dataScope) { + const mergeData = { ...data.data(), ...this.dataScope }; + data.data = () => mergeData; + } } if (renderedComponent.template) { // if this is a pure template or if we are in hybrid vsg mode, diff --git a/src/VueLive.vue b/src/VueLive.vue index a7d92ea..4e2edf2 100644 --- a/src/VueLive.vue +++ b/src/VueLive.vue @@ -6,6 +6,7 @@ :language="lang" :prismLang="prismLang" :requires="requires" + :data-scope="dataScope" :components="components" > @@ -110,6 +112,14 @@ export default { editorProps: { type: Object, default: () => ({}) + }, + /** + * Outside data to the preview + * @example { count: 1 } + */ + dataScope: { + type: Object, + default: () => {} } }, data() {