|
3 | 3 | <html mip>
|
4 | 4 |
|
5 | 5 | <head>
|
6 |
| - <meta charset="utf-8"> |
7 |
| - <title>props</title> |
8 |
| - <meta name="apple-touch-fullscreen" content="yes"> |
9 |
| - <meta name="apple-mobile-web-app-capable" content="yes"> |
10 |
| - <meta name="format-detection" content="telephone=no"> |
11 |
| - <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> |
12 |
| - <style> |
| 6 | + <meta charset="utf-8"> |
| 7 | + <title>props</title> |
| 8 | + <meta name="apple-touch-fullscreen" content="yes"> |
| 9 | + <meta name="apple-mobile-web-app-capable" content="yes"> |
| 10 | + <meta name="format-detection" content="telephone=no"> |
| 11 | + <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> |
| 12 | + <style> |
13 | 13 |
|
14 |
| - </style> |
| 14 | + </style> |
15 | 15 | </head>
|
16 | 16 | <body>
|
17 |
| - <mip-a></mip-a> |
| 17 | + <mip-a> |
| 18 | + <script type="application/json"> |
| 19 | + { |
| 20 | + "mipProps": "mipProps", |
| 21 | + "mip-components": "mip-components" |
| 22 | + } |
| 23 | + </script> |
| 24 | + </mip-a> |
18 | 25 | </body>
|
19 | 26 | <script src="../../dist/mip.js"></script>
|
20 | 27 | <script type="x-tempalte" id="mip-a-template">
|
21 |
| - <div> |
22 |
| - <p>I am mip-a</p> |
23 |
| - <mip-b :userinfo="userinfo"></mip-b> |
24 |
| - <vue-c :userinfo="userinfo"></vue-c> |
25 |
| - </div> |
| 28 | + <div> |
| 29 | + <p>I am mip-a</p> |
| 30 | + <mip-b :userinfo="userinfo"></mip-b> |
| 31 | + <vue-c :userinfo="userinfo"></vue-c> |
| 32 | + </div> |
26 | 33 | </script>
|
27 | 34 |
|
28 | 35 | <script type="x-tempalte" id="mip-b-template">
|
29 |
| - <div> |
30 |
| - <p>I am mip-b </p> |
31 |
| - <p>data from a prop: </p> |
32 |
| - <code>{{userinfo}}</code> |
33 |
| - </div> |
| 36 | + <div> |
| 37 | + <p>I am mip-b </p> |
| 38 | + <p>data from a prop: </p> |
| 39 | + <code>{{userinfo}}</code> |
| 40 | + </div> |
34 | 41 | </script>
|
35 | 42 |
|
36 | 43 | <script type="x-tempalte" id="vue-c-template">
|
37 |
| - <div> |
38 |
| - <p>I am vue-c </p> |
39 |
| - <p>data from a prop: </p> |
40 |
| - <code>{{userinfo}}</code> |
41 |
| - </div> |
| 44 | + <div> |
| 45 | + <p>I am vue-c </p> |
| 46 | + <p>data from a prop: </p> |
| 47 | + <code>{{userinfo}}</code> |
| 48 | + </div> |
42 | 49 | </script>
|
43 | 50 |
|
44 | 51 |
|
45 | 52 | <script>
|
46 |
| -/* global mip */ |
47 |
| -mip.registerVueCustomElement('mip-a', { |
48 |
| - template: '#mip-a-template', |
49 |
| - components: { |
50 |
| - 'vue-c': { |
51 |
| - template: '#vue-c-template', |
52 |
| - props: { |
53 |
| - userinfo: [Object, Array] |
54 |
| - }, |
55 |
| - created() { |
56 |
| - console.log('vue-c: ', this.userinfo); |
57 |
| - } |
58 |
| - } |
59 |
| - }, |
60 |
| - data() { |
61 |
| - return { |
62 |
| - userinfo: [{ |
63 |
| - name: 'fakehuang' |
64 |
| - }] |
65 |
| - }; |
66 |
| - }, |
67 |
| - filters: { |
68 |
| - stringify(data) { |
69 |
| - return typeof data === 'object' && JSON.stringify(data); |
70 |
| - } |
| 53 | +/* global MIP */ |
| 54 | +MIP.registerVueCustomElement('mip-a', { |
| 55 | + template: '#mip-a-template', |
| 56 | + components: { |
| 57 | + 'vue-c': { |
| 58 | + template: '#vue-c-template', |
| 59 | + props: { |
| 60 | + userinfo: [Object, Array] |
| 61 | + }, |
| 62 | + created () { |
| 63 | + console.log('vue-c: ', this.userinfo) |
| 64 | + } |
71 | 65 | }
|
72 |
| -}); |
73 |
| - |
74 |
| -mip.registerVueCustomElement('mip-b', { |
75 |
| - template: '#mip-b-template', |
76 |
| - props: { |
77 |
| - userinfo: { |
78 |
| - default() { |
79 |
| - return {}; |
80 |
| - }, |
81 |
| - type: [Object, Array] |
82 |
| - } |
83 |
| - }, |
84 |
| - data() { |
85 |
| - return { |
86 |
| - }; |
| 66 | + }, |
| 67 | + props: { |
| 68 | + mipProps: { |
| 69 | + type: String, |
| 70 | + default: '' |
87 | 71 | },
|
88 |
| - created() { |
89 |
| - console.log('mip-b: ', this.userinfo); |
| 72 | + 'mip-components': { |
| 73 | + type: String, |
| 74 | + default: '' |
| 75 | + } |
| 76 | + }, |
| 77 | + data () { |
| 78 | + return { |
| 79 | + userinfo: [{ |
| 80 | + name: 'fakehuang' |
| 81 | + }] |
90 | 82 | }
|
91 |
| -}); |
| 83 | + }, |
| 84 | + mounted () { |
| 85 | + console.log(this.mipProps) // 空 |
| 86 | + console.log(this.mipComponents) // mip-components |
| 87 | + }, |
| 88 | + filters: { |
| 89 | + stringify (data) { |
| 90 | + return typeof data === 'object' && JSON.stringify(data) |
| 91 | + } |
| 92 | + } |
| 93 | +}) |
92 | 94 |
|
| 95 | +MIP.registerVueCustomElement('mip-b', { |
| 96 | + template: '#mip-b-template', |
| 97 | + props: { |
| 98 | + userinfo: { |
| 99 | + default () { |
| 100 | + return {} |
| 101 | + }, |
| 102 | + type: [Object, Array] |
| 103 | + } |
| 104 | + }, |
| 105 | + data () { |
| 106 | + return { |
| 107 | + } |
| 108 | + }, |
| 109 | + created () { |
| 110 | + console.log('mip-b: ', this.userinfo) |
| 111 | + } |
| 112 | +}) |
93 | 113 | </script>
|
94 | 114 | </html>
|
95 | 115 |
|
0 commit comments