Skip to content

Commit 7509709

Browse files
wip(docs): update Vue2 example
1 parent 4cdd138 commit 7509709

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/examples.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,19 @@ node -e "require('express')().use(require('express').static(__dirname, {index:'i
4343
/* <!-- */
4444
const mainComponent = `
4545
<template>
46-
<span>Hello World !</span>
46+
<span>Hello from Vue {{ require('myData').vueVersion }} !</span>
4747
</template>
4848
`;
4949
/* --> */
5050
51+
const { loadModule, vueVersion } = window['vue2-sfc-loader'];
52+
5153
const options = {
5254
moduleCache: {
5355
vue: Vue,
56+
myData: {
57+
vueVersion,
58+
}
5459
},
5560
getFile(url) {
5661
@@ -60,15 +65,14 @@ node -e "require('express')().use(require('express').static(__dirname, {index:'i
6065
addStyle() {},
6166
}
6267
63-
const { loadModule, vueVersion } = window['vue2-sfc-loader'];
6468
loadModule('./main.vue', options)
6569
.then(component => new Vue(component).$mount('#app'));
6670
</script>
6771
</body>
6872
</html>
6973
```
7074
<!--example:target:vue2_basic_example-->
71-
[open in JSBin ▶](http://jsbin.com/?html,output&html=%3C!DOCTYPE+html%3E%0A%3Chtml%3E%0A%3Cbody%3E%0A++%3Cdiv+id%3D%22app%22%3E%3C%2Fdiv%3E%0A++%3Cscript+src%3D%22https%3A%2F%2Funpkg.com%2Fvue%22%3E%3C%2Fscript%3E%0A++%3Cscript+src%3D%22https%3A%2F%2Fcdn.jsdelivr.net%2Fnpm%2Fvue3-sfc-loader%400.6.0%2Fdist%2Fvue2-sfc-loader.js%22%3E%3C%2Fscript%3E%0A++%3Cscript%3E%0A%0A++++%2F*+%3C!--+*%2F%0A++++const+mainComponent+%3D+%60%0A++++++%3Ctemplate%3E%0A++++++++%3Cspan%3EHello+World+!%3C%2Fspan%3E%0A++++++%3C%2Ftemplate%3E%0A++++%60%3B%0A++++%2F*+--%3E+*%2F%0A%0A++++const+options+%3D+%7B%0A++++++moduleCache%3A+%7B%0A++++++++vue%3A+Vue%2C%0A++++++%7D%2C%0A++++++getFile(url)+%7B%0A%0A++++++++if+(+url+%3D%3D%3D+'%2Fmain.vue'+)%0A++++++++++return+Promise.resolve(mainComponent)%3B%0A++++++%7D%2C%0A++++++addStyle()+%7B%7D%2C%0A++++%7D%0A%0A++++const+%7B+loadModule%2C+vueVersion+%7D+%3D+window%5B'vue2-sfc-loader'%5D%3B%0A++++loadModule('.%2Fmain.vue'%2C+options)%0A++++.then(component+%3D%3E+new+Vue(component).%24mount('%23app'))%3B%0A++%3C%2Fscript%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A)
75+
[open in JSBin ▶](http://jsbin.com/?html,output&html=%3C!DOCTYPE+html%3E%0A%3Chtml%3E%0A%3Cbody%3E%0A++%3Cdiv+id%3D%22app%22%3E%3C%2Fdiv%3E%0A++%3Cscript+src%3D%22https%3A%2F%2Funpkg.com%2Fvue%22%3E%3C%2Fscript%3E%0A++%3Cscript+src%3D%22https%3A%2F%2Fcdn.jsdelivr.net%2Fnpm%2Fvue3-sfc-loader%400.6.0%2Fdist%2Fvue2-sfc-loader.js%22%3E%3C%2Fscript%3E%0A++%3Cscript%3E%0A%0A++++%2F*+%3C!--+*%2F%0A++++const+mainComponent+%3D+%60%0A++++++%3Ctemplate%3E%0A++++++++%3Cspan%3EHello+from+Vue+%7B%7B+require('myData').vueVersion+%7D%7D+!%3C%2Fspan%3E%0A++++++%3C%2Ftemplate%3E%0A++++%60%3B%0A++++%2F*+--%3E+*%2F%0A%0A++++const+%7B+loadModule%2C+vueVersion+%7D+%3D+window%5B'vue2-sfc-loader'%5D%3B%0A%0A++++const+options+%3D+%7B%0A++++++moduleCache%3A+%7B%0A++++++++vue%3A+Vue%2C%0A++++++++myData%3A+%7B%0A++++++++++vueVersion%2C%0A++++++++%7D%0A++++++%7D%2C%0A++++++getFile(url)+%7B%0A%0A++++++++if+(+url+%3D%3D%3D+'%2Fmain.vue'+)%0A++++++++++return+Promise.resolve(mainComponent)%3B%0A++++++%7D%2C%0A++++++addStyle()+%7B%7D%2C%0A++++%7D%0A%0A++++loadModule('.%2Fmain.vue'%2C+options)%0A++++.then(component+%3D%3E+new+Vue(component).%24mount('%23app'))%3B%0A++%3C%2Fscript%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A)
7276
<!--/example:target:vue2_basic_example-->
7377
[:top:](#readme)
7478

0 commit comments

Comments
 (0)