Olá Flávio, Tudo bem?
Sou novo no curso de vue 2.0, estou começando a criar alguns componentes, só que estou recebendo o seguinte problema no console.
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "ndrawer"
found in
Devo estar passando minha prop da maneira errada.
Estou querendo em App.vue criar inserir um componente chamado Navigation.vue ele faz comunicação pelo v-model.
meu componente está escrito assim.
Navegation.vue
<template>
<v-navigation-drawer v-if="loggedIn" fixed :mini-variant="true" :clipped="false" v-model="ndrawer" class="secondary" app>
<v-list class="primary">
<v-list-tile v-for="(item, i) in items" :key="i" value="true">
<v-list-tile-action>
<v-icon style="color:#fff;" light v-html="item.icon"></v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title style="color:#fff;" v-text="item.title"></v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
</template>
<script>
export default {
props: [
'loggedIn',
'ndrawer'
],
data() {
return {
items: [{
icon: 'library_add',
title: 'Biblioteca'
}],
}
},
}
</script>
Chamada principal dele é está
App.vue
<template>
<v-app light>
<dr-navigation :loggedIn="$store.state.isUserLoggedIn" :ndrawer="drawer">
</dr-navigation>
<dr-toolbar :loggedIn="$store.state.isUserLoggedIn">
<v-layout row justify-space-between>
<v-flex xs2 style="margin-top:12px;">
<v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon>
</v-flex>
<v-flex xs2>
<center>
<img src="/static/logo-domrock-nav.png" alt="Dom Rock" />
</center>
</v-flex>
<v-flex xs2 style="margin-top:12px;">
<div style="float:right;">
<v-btn icon @click.stop="rightDrawer = !rightDrawer">
<v-icon>menu</v-icon>
</v-btn>
</div>
<v-spacer></v-spacer>
<div style="float:right;">
<v-btn icon @click="onLogout()">
<v-icon>person</v-icon>
</v-btn>
</div>
</v-flex>
</v-layout>
</dr-toolbar>
<dr-footer></dr-footer>
</v-app>
</template>
<script>
import Toolbar from '@/components/Shared/ToolBar'
import Navigation from '@/components/Shared/Navigation'
import Footer from '@/components/Shared/Footer'
export default {
components: {
'dr-toolbar': Toolbar,
'dr-navigation': Navigation,
'dr-footer': Footer,
},
data() {
return {
clipped: false,
drawer: true,
fixed: false,
miniVariant: false,
right: true,
rightDrawer: false,
title: ''
}
},
methods: {
onLogout() {
alert("deslogar")
},
}
}
</script>
<style lang="stylus" scoped>
@import "../stylus/login"
</style>
O problema está em :ndrawer="drawer" está variavel estou realizando a interpolação passando em 2 componentes só que quando fecho o sidebar recebo a seguinte mensagem
vue.runtime.esm.js?a427:570 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "ndrawer"
found in
---> <DrNavigation> at src/components/Shared/Navigation.vue
<VApp>
<App> at src/App.vue
<Root>
Se você conseguir me dar uma luz já vai ajudar e muito.