File tree Expand file tree Collapse file tree 1 file changed +99
-0
lines changed Expand file tree Collapse file tree 1 file changed +99
-0
lines changed Original file line number Diff line number Diff line change @@ -520,6 +520,105 @@ In the following example we use a trick to preserve reactivity through the `Vue.
520
520
521
521
522
522
523
+
524
+ ## Nested components
525
+
526
+ <!-- example:source:nested_components-->
527
+ ``` html
528
+ <!DOCTYPE html>
529
+ <html >
530
+ <body >
531
+ <script src =" https://unpkg.com/vue@next" ></script >
532
+ <
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/vue3-sfc-loader.js" ></
script >
533
+ <script >
534
+
535
+ /* <!-- */
536
+ const config = {
537
+ files: {
538
+ ' /main.vue' : `
539
+ <template>
540
+ <foo/>
541
+ </template>
542
+ <script>
543
+ import foo from './foo.vue'
544
+
545
+ export default {
546
+ components: {
547
+ foo,
548
+ },
549
+ created() {
550
+ console.log('main created')
551
+ },
552
+ mounted() {
553
+ console.log('main mounted')
554
+ }
555
+ }
556
+ </script>
557
+ ` ,
558
+
559
+ ' /foo.vue' : `
560
+ <template>
561
+ <bar/>
562
+ </template>
563
+ <script>
564
+ import bar from './bar.vue'
565
+
566
+ export default {
567
+ components: {
568
+ bar,
569
+ },
570
+ created() {
571
+ console.log('foo created')
572
+ },
573
+ mounted() {
574
+ console.log('foo mounted')
575
+ }
576
+ }
577
+ </script>
578
+ ` ,
579
+
580
+ ' /bar.vue' : `
581
+ <template>
582
+ end
583
+ </template>
584
+ <script>
585
+
586
+ export default {
587
+ components: {
588
+ },
589
+ created() {
590
+ console.log('bar created')
591
+ },
592
+ mounted() {
593
+ console.log('bar mounted')
594
+ }
595
+ }
596
+ </script>
597
+ `
598
+ }
599
+ };
600
+ /* --> */
601
+
602
+
603
+ const options = {
604
+ moduleCache: { vue: Vue },
605
+ getFile : url => config .files [url],
606
+ addStyle : () => {},
607
+ }
608
+
609
+ Vue .createApp (Vue .defineAsyncComponent (() => window [' vue3-sfc-loader' ].loadModule (' /main.vue' , options))).mount (document .body );
610
+
611
+ </script >
612
+ </body >
613
+ </html >
614
+ ```
615
+ <!-- example:target:nested_components-->
616
+ <!-- /example:target:nested_components-->
617
+ [ :top : ] ( #readme )
618
+
619
+
620
+
621
+
523
622
<!-- -
524
623
525
624
const regexpReservedChars = '\\.+*?^$|[{()';
You can’t perform that action at this time.
0 commit comments