Skip to content

Commit cf05f7e

Browse files
wip(docs): update examples
1 parent 5b9920e commit cf05f7e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

docs/examples.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -798,18 +798,18 @@ In the following example we use a trick to preserve reactivity through the `Vue.
798798
const config = {
799799
files: {
800800
'/main.vue': {
801-
content: /* <!-- */`
801+
getContentData: () => /* <!-- */`
802802
<template>
803803
<pre><b>'url!./circle.svg' -> </b>{{ require('url!./circle.svg') }}</pre>
804804
<img width="50" height="50" src="~url!./circle.svg" />
805805
<pre><b>'file!./circle.svg' -> </b>{{ require('file!./circle.svg') }}</pre>
806-
<img width="50" height="50" src="~file!./circle.svg" />
806+
<img width="50" height="50" src="~file!./circle.svg" /> <br><i>(image failed to load, this is expected since there is nothing behind this url)</i>
807807
</template>
808808
`/* --> */,
809809
type: '.vue',
810810
},
811811
'/circle.svg': {
812-
content: /* <!-- */`
812+
getContentData: () => /* <!-- */`
813813
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
814814
<circle cx="50" cy="50" r="50" />
815815
</svg>
@@ -834,10 +834,10 @@ In the following example we use a trick to preserve reactivity through the `Vue.
834834
throw new Error(`${ type } not handled by url!`);
835835
},
836836
},
837-
handleModule(type, source, path, options) {
837+
handleModule(type, getContentData, path, options) {
838838
839839
switch (type) {
840-
case '.svg': return source;
840+
case '.svg': return getContentData(false);
841841
default: return undefined; // let vue3-sfc-loader handle this
842842
}
843843
},
@@ -872,10 +872,9 @@ In the following example we use a trick to preserve reactivity through the `Vue.
872872
path,
873873
async getContent() {
874874
875-
const { content, type } = await getFile(path);
876-
875+
const { getContentData, type } = await getFile(path);
877876
return {
878-
content: processContentThroughLoaders(content, path, type, options),
877+
getContentData: async (asBinary) => processContentThroughLoaders(await getContentData(asBinary), path, type, options),
879878
type,
880879
};
881880
}
@@ -938,7 +937,7 @@ This example use Vue2 because **vue-calendar-picker** is written for Vue2.
938937
if ( new URL(url).pathname === '/main.vue' ) {
939938
940939
return {
941-
content: /*<!--*/`
940+
getContentData: () => /*<!--*/`
942941
<template>
943942
<div>
944943
<calendar-range locale="EN" :selection="selection" :events="calendarEvents"/>

0 commit comments

Comments
 (0)