<template>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">My App</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="#"
id="navbarDropdown"
role="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
<i class="fa fa-bell"></i>
<span class="badge badge-pill badge-danger">{{ notifications.length }}</span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<div v-if="notifications.length > 0" class="list-group">
<a
v-for="(notification, index) in notifications"
:key="index"
href="#"
class="list-group-item list-group-item-action"
@click.prevent="markNotificationAsRead(index)"
>
{{ notification }}
</a>
</div>
<div v-else class="dropdown-item text-muted">No new notifications</div>
</div>
</li>
</ul>
</div>
</div>
</nav>
</template>
<script>
export default {
name: "Navbar",
data() {
return {
notifications: ["Notification 1", "Notification 2", "Notification 3"],
};
},
methods: {
markNotificationAsRead(index) {
this.notifications.splice(index, 1);
},
},
};
</script>
<style>
/* Add any custom styles here */
</style>