I am facing a challenge with rotating an arrow icon within a dropdown menu. Despite my efforts, the rotation does not synchronize with the appearance of the dropdown menu. Here is the Vue component code snippet:
<nav>
<section class="nav-item" @click="showDropdown = !showDropdown">
<div class="nav-icon">
<img src="../../../assets/img/users.svg" />
</div>
<h4>Users</h4>
<div class="arrow" :class="arrowLeft">
<img src="../../../assets/img/arrow_down.svg" />
</div>
<div v-if="showDropdown">
<span class="sub-nav-item">Import</span>
<span class="sub-nav-item">Invitations</span>
</div>
</section>
<section class="nav-item">
<div class="nav-icon">
<img src="../../../assets/img/polls.svg" />
</div>
<h4>Poll</h4>
</section>
</nav>
My attempts to resolve this issue in the script tags are as follows:
<script>
export default {
data() {
return {
showDropdown: false,
};
},
computed: {
arrowLeft() {
let arrow = 'turn-arrow';
if (this.showDropdown === true) {
return arrow;
}
return true;
},
},
};
</script>
For CSS styling, I have implemented the following styles:
.arrow {
display: inline;
height: 7px;
width: 13px;
margin-left: 13px;
}
.turn-arrow {
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}