File tree Expand file tree Collapse file tree 4 files changed +1604
-0
lines changed Expand file tree Collapse file tree 4 files changed +1604
-0
lines changed Original file line number Diff line number Diff line change
1
+ < body > </ body >
2
+
3
+ < script src ="./static/mini-vue.umd.js "> </ script >
4
+
5
+ < script >
6
+ const { compileToFunction } = MiniVue
7
+
8
+ const template = `<div id="foo" class="bar"><p>{{ msg }}</p><p>Template</p></div>`
9
+ const render = compileToFunction ( template )
10
+
11
+ console . log ( '模板:' , template )
12
+ console . log ( render )
13
+ </ script >
14
+
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < title > Document</ title >
7
+ < script src ="./static/mini-vue.umd.js "> </ script >
8
+ < style >
9
+ .red {
10
+ color : red;
11
+ }
12
+ .demo {
13
+ position : absolute;
14
+ top : 50% ;
15
+ left : 50% ;
16
+ transform : translate (-50% , -50% );
17
+ }
18
+ .count {
19
+ margin : 0 10px ;
20
+ }
21
+ </ style >
22
+ </ head >
23
+ < body >
24
+ < div id ="app "> < div class ="demo "> < button @click ="minus "> -1</ button > < span class ="count "> {{ count }}</ span > < button @click ="plus "> +1</ button > </ div > </ div >
25
+ < script >
26
+ const { createApp, ref } = MiniVue
27
+ const count = ref ( 0 )
28
+
29
+ createApp ( {
30
+ setup ( ) {
31
+ const plus = ( ) => {
32
+ count . value ++
33
+ }
34
+ const minus = ( ) => {
35
+ count . value --
36
+ }
37
+ return {
38
+ count,
39
+ plus,
40
+ minus
41
+ }
42
+ }
43
+ } ) . mount ( '#app' )
44
+ </ script >
45
+ </ body >
46
+ </ html >
You can’t perform that action at this time.
0 commit comments