File tree 5 files changed +54
-16
lines changed
5 files changed +54
-16
lines changed Original file line number Diff line number Diff line change 1
1
<script setup>
2
2
import { RouterView } from ' vue-router'
3
3
import RouterButton from " @/components/RouterButton.vue" ;
4
+ import { introExamples } from " @/examplelists.js" ;
4
5
5
6
</script >
6
7
7
8
<template >
8
9
<div class =" flex flex-row gap-x-2 h-full w-full" >
9
- <div class =" flex flex-col w-36 p-2" >
10
- <div class =" flex flex-col" >
11
- <h2 >Introduction</h2 >
12
- <RouterButton to-path =" /helloworld" name =" Hello World" />
13
- <RouterButton to-path =" /dynamicattributes" name =" Dynamic Attributes" />
14
- <RouterButton to-path =" /styling" name =" Styling" />
15
- <RouterButton to-path =" /nestedcomponents" name =" Nested Component" />
16
- <RouterButton to-path =" /htmldirective" name =" HTML Directive" />
10
+ <div class =" flex flex-col w-56 p-2" >
11
+ <p class =" text-2xl" >Vue 3 Examples</p >
12
+ <br >
13
+ <div class =" flex flex-col gap-y-2" >
14
+ <p class =" text-xl" >Introduction</p >
15
+ <RouterButton
16
+ v-for =" example in introExamples"
17
+ :key =" example.name"
18
+ :to-path =" example.path"
19
+ :name =" example.name"
20
+ />
17
21
</div >
18
22
19
23
</div >
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ store.setFiles({
25
25
})
26
26
27
27
28
-
29
28
</script >
30
29
31
30
<template >
Original file line number Diff line number Diff line change 1
1
<script setup>
2
+ import { defineProps , computed } from ' vue' ;
3
+ import { useRoute } from ' vue-router' ;
4
+
2
5
const props = defineProps ({
3
6
toPath: {
4
7
type: String ,
@@ -8,20 +11,29 @@ const props = defineProps({
8
11
type: String ,
9
12
default: ' /'
10
13
}
11
- })
14
+ });
12
15
16
+ const route = useRoute ();
17
+ const isSelected = computed (() => route .path === props .toPath );
13
18
</script >
14
19
15
20
<template >
16
21
<button
17
- class =" bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-2 border border-gray-400 rounded shadow"
22
+ : class =" {'selected': isSelected, ' bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-2 border border-gray-400 rounded shadow': true} "
18
23
@click =" $router.push(props.toPath)"
19
24
>
20
25
{{ props.name }}
21
26
</button >
22
-
23
27
</template >
24
28
25
29
<style scoped>
30
+ .selected {
31
+ background-color : #0056b3 ;
32
+ color : white ;
33
+ }
34
+
35
+ button .selected :hover {
36
+ background-color : #0056b3 ;
37
+ }
26
38
27
39
</style >
Original file line number Diff line number Diff line change
1
+
2
+ export const introExamples = [
3
+ {
4
+ name : "Hello World" ,
5
+ path : "/helloworld"
6
+ } ,
7
+ {
8
+ name : "Dynamic Attributes" ,
9
+ path : '/dynamicattributes' ,
10
+ } ,
11
+ {
12
+ name : "Styling" ,
13
+ path : '/styling'
14
+ } ,
15
+ {
16
+ name : "Nested Component" ,
17
+ path : '/nestedcomponents'
18
+ } ,
19
+ {
20
+ name : "HTML Directive" ,
21
+ path : '/htmldirective'
22
+ }
23
+ ]
Original file line number Diff line number Diff line change 1
1
export const AppVue = `
2
2
<!-- Dynamically rendering arbitrary HTML on your website can be very dangerous because it can easily lead to XSS attacks. Only use v-html on trusted content and never on user-provided content. -->
3
- <script setup>
4
- const htmlString = \`hello <b>world</b>\`;
5
- </script>
6
-
7
3
<template>
8
4
<p v-html="htmlString"></p>
9
5
</template>
6
+
7
+ <script setup>
8
+ const htmlString = \`hello <b>world</b>\`;
9
+ </script>
10
10
` . trimStart ( )
You can’t perform that action at this time.
0 commit comments