I have been trying to make a dropdown
open and close normally (animate it) using what I have just learned from a slightly out of date VueJs course, but it does not work. I will further after set my routing there.
It seems that before, in Bootstrap, instead of using .show
it used .open
for dropdown lists.
I thought that I could play around with a @click
method and make it work. If you switch the Boolean
at data
to true, the dropdown
will be open by default, but I do now understand why it won't obey the v-on
directive when switching the boolean
statement from true
to false
and so on.
HTML below
<template>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<router-link to="/" class="navbar-brand"><a>Stock Trade</a></router-link>
<div class="collapse navbar-collapse">
<ul class="navbar-nav mr-auto">
<router-link :to="{ name: 'portfolio'}" tag="li" class="nav-item nav-link"><a>Portfolio</a></router-link>
<router-link :to="{name: 'stocks'}" tag="li" class="nav-item nav-link"><a>Stocks</a></router-link>
</ul>
</div>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item nav-link">End Day</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle"
href="#"
role="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
Save & Load <span class="dropdown-toggle-no-caret"></span>
</a>
<!-- I must understand why it does not work below-->
<div class="dropdown-menu"
:class="{show: isDropping}"
@click="isDropping = !isDropping"
aria-labelledby="navbarDropdown">
<a class="dropdown-item " href="#">Save Data</a>
<a class="dropdown-item" href="#">Load Data</a>
</div>
</li>
<strong class="navbar-text" style="color: dimgray">Funds: {{$store.state.funds + ' EUR'}}</strong>
</ul>
</div>
</nav>
</template>
Script part below
<script>
export default {
data() {
return {
isDropping: false
}
}
}
</script>
I have hardcoded some style
in the template
are and below just for now until I am trying to set things up.
<style scoped>
a {
color: dimgray;
}
</style>
Thanks in advance to all.