1π
(I removed all props/attributes unrelated to the question)
<v-navigation-drawer v-model="leftDrawer">
This is mutating the leftDrawer
prop. Read the docs to learn what v-model actually does.
Try this, but I doubt itβll work. It depends on how v-navigation-drawer
implements v-model. Again, this is in the docs βv-model on custom components.β
<v-navigation-drawer :value="leftDrawer" @input="$emit('leftChange')">
Even if you look at the error, you donβt know what is causing it.
Depends on your vue experience.
EDIT: Mistake in my answer.
@input="$emit('input', $event)"
should be @input="$emit('leftChange')"
.
Because the parent component main.vue
is listening for v-on:leftChange="leftChange"
on the LeftSidebar
.
0π
Try this below :
<template>
<v-navigation-drawer app v-model="left_drawer" clipped class="yellow">
</v-navigation-drawer>
</template>
<script>
export default {
props: {
leftDrawer: Boolean
},
data(){
return {
left_drawer : this.defaultSelected()
}
},
methods:{
defaultSelected(){
return this.leftDrawer;
}
}
</script>
This is because you are mutating a prop directly, so in your child component, first define a variable for your prop and then assign a value to it using a method or a computed property.
0π
I do think it is because of your v-model="leftDrawer"
in LeftSidebar.vue
.
v-model
will update the value of the specified variable when it has been internally mutated in the v-navigation-drawer
. In your situation, it will try to mutate the value of the passed leftDrawer
prop. Hence, the error message.
The solution would be to assign (in LeftSidebar.vue
) your leftDrawer
prop in a data attribute and use this attribute with v-bind
. If you need to communicate this change to your main.vue
component, emit the event as you did in Header
.
Personal opinion after some projects with this scenario, I find it easier to manage by saving these states in an app
or ui
vuex store.
Hope this will help
[EDITED]
If the implementation of v-navigation-drawer
allows it, the solution presented by @Eric Guan is the way to go
- [Vuejs]-Pause functions on page history forward backward
- [Vuejs]-Render button based on checkbox count