File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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+ < link rel ="icon " type ="image/svg+xml " href ="/vite.svg " />
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7+ < title > Vite + Vue</ title >
8+ </ head >
9+ < body >
10+ < div id ="app "> </ div >
11+ < script type ="module " src ="/src/score.js "> </ script >
12+ </ body >
13+ </ html >
Original file line number Diff line number Diff line change 1+ <script setup>
2+ import {ref } from " vue" ;
3+
4+ const score = ref (40 );
5+ </script >
6+
7+ <template >
8+ <h1 >Score App</h1 >
9+
10+ <div v-show =" score > 50" >
11+ Score is {{score}}
12+ </div >
13+ <div v-if =" score > 90" >
14+ Yay cool score {{score}}
15+ </div >
16+ <div v-else-if =" score > 70" >
17+ Good score {{score}}
18+ </div >
19+ <div v-else >
20+ Ups, bad score {{score}}
21+ </div >
22+ </template >
23+
24+ <style scoped>
25+
26+ </style >
Original file line number Diff line number Diff line change 1+ <script setup>
2+
3+
4+ import {ref } from " vue" ;
5+
6+ const array = [" red" , " bold" ];
7+
8+ const red = ref (false );
9+ const bold = ref (false );
10+
11+ function toggleRed () {
12+ red .value = ! red .value ;
13+ }
14+
15+ function toggleBold () {
16+ bold .value = ! bold .value ;
17+ }
18+
19+ const style1 = {
20+ color: " red"
21+ }
22+
23+ const style2 = {
24+ textTransform: " uppercase" ,
25+ fontWeight: " bold"
26+ }
27+
28+ </script >
29+
30+ <template >
31+ <h1 :class =" {red:red, bold: bold}" >Style</h1 >
32+ <h1 :class =" array" >Style</h1 >
33+
34+ <h1 :style =" style1" >Style</h1 >
35+ <h1 :style =" style2" >Style</h1 >
36+ <h1 :style =" [style1, style2]" >Style</h1 >
37+
38+ <button v-on:click =" toggleRed" >Red</button >
39+ <button v-on:click =" toggleBold" >Bold</button >
40+ </template >
41+
42+ <style scoped>
43+ .red {
44+ color : red ;
45+ }
46+
47+ .bold {
48+ text-transform : uppercase ;
49+ font-weight : bold ;
50+ }
51+ </style >
Original file line number Diff line number Diff line change 1+ import { createApp } from "vue" ;
2+ import Score from "./components/Score.vue" ;
3+
4+ createApp ( Score ) . mount ( "#app" ) ;
Original file line number Diff line number Diff line change 1+ import { createApp } from "vue" ;
2+ import Style from "./components/Style.vue" ;
3+
4+ createApp ( Style ) . mount ( "#app" ) ;
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+ < link rel ="icon " type ="image/svg+xml " href ="/vite.svg " />
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7+ < title > Vite + Vue</ title >
8+ </ head >
9+ < body >
10+ < div id ="app "> </ div >
11+ < script type ="module " src ="/src/style.js "> </ script >
12+ </ body >
13+ </ html >
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ export default defineConfig({
1111 hello : "hello.html" ,
1212 counter : "counter.html" ,
1313 say_hello : "say-hello.html" ,
14+ style : "style.html" ,
15+ score : "score.html" ,
1416 }
1517 }
1618 }
You can’t perform that action at this time.
0 commit comments