0๐
- Define
showDropdown
in data - Use
v-show="showDropdown"
on what you want to hide - Define
@click="showDropdown = !showDropdown"
on the dropdown header to toggle the dropdown - Set
showDropdown = false
on submit
<template>
<Dropdown>
<div
type="button"
aria-haspopup="true"
aria-expanded="false"
@click="showDropdown = !showDropdown"
>
Show Dropdown
</div>
<div v-show="showDropdown">
<button
@click="submit"
>
Click me
</button>
</div>
</Dropdown>
</template>
<script>
import { defineComponent } from "vue";
export default defineComponent({
data(){
return {
showDropdown: false
}
},
methods: {
submit() {
this.showDropdown = false;
// do more
}
}
});
</script>
If you need it to be a template, you can use v-if
instead of v-show
- [Vuejs]-Import errors for ThreeJS in vue-test-utils with Jest
- [Vuejs]-GET Request repeatedly failed on the front end but not on backend
Source:stackexchange.com