File tree Expand file tree Collapse file tree 1 file changed +30
-34
lines changed Expand file tree Collapse file tree 1 file changed +30
-34
lines changed Original file line number Diff line number Diff line change 2
2
< html >
3
3
< body >
4
4
< div id ="app "> </ div >
5
- < script src ="https://unpkg.com/vue@2/dist/vue.js "> </ script >
6
- < script src ="vue2-sfc-loader.js "> </ script >
5
+ < script src ="https://unpkg.com/vue@2/dist/vue.runtime.min. js "> </ script >
6
+ < script src ="
https://cdn.jsdelivr.net/npm/[email protected] /dist/ vue2-sfc-loader.js"
> </ script >
7
7
< script >
8
8
9
9
/* <!-- */
10
10
const config = {
11
11
files : {
12
- '/app.vue' : `
13
- <template>
14
- <span class="vue2">
15
- Hello World! {{ abc }}
16
- </span>
17
- </template>
18
- <style scoped>
19
- .vue2 {
20
- background: red
21
- }
22
- </style>
23
- <script>
24
- export default {
25
- data: {
26
- abc: "test"
27
- }
28
- }
29
- <\/script>
30
- `
12
+ '/app.vue' :
13
+ ' <template> ' +
14
+ ' <div>{{ index }}</div> ' +
15
+ ' </template> ' +
16
+ ' <script> ' +
17
+ ' ' +
18
+ ' export default { ' +
19
+ ' data() { ' +
20
+ ' return { ' +
21
+ ' index: 0, ' +
22
+ ' } ' +
23
+ ' }, ' +
24
+ ' async mounted() { ' +
25
+ ' ' +
26
+ ' for ( ; this.index < 100; ++this.index ) ' +
27
+ ' await new Promise(resolve => setTimeout(resolve, 1000)); ' +
28
+ ' } ' +
29
+ ' } ' +
30
+ ' </ script > '+
31
+ '',
31
32
}
32
33
};
33
- /* --> */
34
-
34
+
35
35
const options = {
36
36
moduleCache: { vue: Vue },
37
- getFile : url => config . files [ url ] ,
38
- addStyle : ( textContent ) => {
39
- const style = Object . assign ( document . createElement ( 'style' ) , { textContent } ) ;
40
- const ref = document . head . getElementsByTagName ( 'style' ) [ 0 ] || null ;
41
- document . head . insertBefore ( style , ref ) ;
42
- } ,
37
+ getFile: function(url) { return config.files[url] },
38
+ addStyle: function () {},
43
39
}
44
40
45
- const asyncComponentFactory = window [ 'vue2-sfc-loader' ] . loadModule ( '/app.vue' , options )
46
- asyncComponentFactory . then ( ( component ) => {
47
- new Vue ( component ) . $mount ( '#app' )
48
- } )
49
-
41
+ window['vue2-sfc-loader'].loadModule('/app.vue', options)
42
+ .then(function(app) {
43
+ new Vue(app ).$mount('#app')
44
+ });
45
+
50
46
</ script >
51
47
</ body >
52
48
</ html >
You can’t perform that action at this time.
0 commit comments