-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-binding.html
77 lines (75 loc) · 3.15 KB
/
class-binding.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<title></title>
</head>
<body>
<div id="app">
<nav class="navbar navbar-expand-lg"
:class="{'navbar-dark bg-dark':navBarToggle,'navbar-light bg-light': !navBarToggle}"
>
<div class="container-fluid">
<a class="navbar-brand" href="#">{{ main }}</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item" v-for="(page,index) in pages">
<a class="nav-link"
:class="{'active':activePage==index}"
aria-current="page"
:href="page.link.url"
:title="`This links goes to the ${page.link.Text} page`"
:key="index"
@click.prevent="activePage=index">{{ page.link.Text }}</a>
</li>
</ul>
<form action="" class="d-flex">
<button @click.prevent="navBarToggle=!navBarToggle" class="btn btn-primary">Navbar Toggle</button>
</form>
</div>
</div>
</nav>
<div class="row">
<h3>{{ pages[activePage].pageTitle }}</h3>
<p>{{ pages[activePage].content }}</p>
</div>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script>
Vue.createApp({
data(){
return{
pageTitle:"Binding data to attributes",
main:'Navbar',
activePage:0,
navBarToggle:true,
pages:[
{
link:{Text:'Home',url:'index.html'},
pageTitle:"Home Page",
content:"This is the Home Conetnt"
},
{
link:{Text:'About Us',url:'about-us.html'},
pageTitle:"About Us Page",
content:"This is the About Conetnt"
},
{
link:{Text:'Contact Us',url:'contact-us.html'},
pageTitle:"Contact Us Page",
content:"This is the Contact Conetnt"
},
]
}
}
}).mount("#app");
</script>
</html>