1👍
I was able to fix the problem by placing the component inside a div tag and moving the v-show on the parent div. Here’s a adjusted code:
<div v-show="isMoe">
<Moe />
</div>
<Larry />
<Curly />
import Moe from "@/components/Moe.vue";
import Larry from "@/components/Larry.vue";
import Curly from "@/components/Curly.vue";
export default {
data: function() {
return {
stooge: "Curly"
}
},
components: {
Moe,
Larry,
Curly
},
computed: {
isMoe() {
return this.stooge === "Moe"
}
}
}
- [Vuejs]-Highmaps in VueJs….pass a State to mapOptions
- [Vuejs]-How to dynamically add/remove a new form row with select/autocomplete values in vuetify?
0👍
Maybe it’s a terminology issue, but v-show
will always render a component. It will simply add a style="display: none;"
style and toggle that to block
.
Your code looks correct so it should behave as expected. Is it not adding the style="display: none;"
when v-show is false
?
As an additional note. It is better practice to use ===
instead of ==
:
return this.stooge === "Moe"
- [Vuejs]-Why am I able to display an entire JSON object, but not get a value from inside it?
- [Vuejs]-Vue.js How to watcher before mounted() , can't get data from watch
Source:stackexchange.com