【发布时间】:2020-03-27 11:38:45
【问题描述】:
在我的Vue.JS 应用程序中,我尝试使用Vuetify 框架中的两个v-navigation-drawer。出于某种原因,我的下一个代码引发了错误。就我而言,每个侧边栏都在一个单独的组件中。如何解决此类错误?
错误:
vue.esm.js?efeb:628 [Vue 警告]:避免直接改变 prop,因为 每当父组件时,该值将被覆盖 重新渲染。相反,使用基于 道具的价值。正在变异的道具:“打开”
BaseLayout.vue:
<template>
<div>
<v-app-bar app>
<v-btn
icon
@click.stop="openLeftNavigationDrawer=!openLeftNavigationDrawer">
<v-icon>mdi-map-clock-outline</v-icon>
</v-btn>
<v-spacer></v-spacer>
<v-btn
icon
@click.stop="openRightNavigationDrawer=!openRightNavigationDrawer">
<v-icon>mdi-filter</v-icon>
</v-btn>
</v-app-bar>
<left-navigation-drawer
:open="openLeftNavigationDrawer">
</left-navigation-drawer>
<right-navigation-drawer
:open="openRightNavigationDrawer">
</right-navigation-drawer>
<v-content style="padding:unset!important;">
<slot></slot>
</v-content>
</div>
</template>
<script>
import LeftNavigationDrawer from '../elements/LeftNavigationDrawer'
import RightNavigationDrawer from '../elements/RightNavigationDrawer'
export default {
name: 'BaseLayout',
components: {
LeftNavigationDrawer,
RightNavigationDrawer
},
data: function () {
return {
openLeftNavigationDrawer: false,
openRightNavigationDrawer: false
}
}
}
</script>
LeftNavigationDrawer.vue:
<template>
<v-navigation-drawer
v-model="open"
absolute
left>
</v-navigation-drawer>
</template>
<script>
export default {
name: 'LeftNavigationDrawer',
props: {
open: false
}
}
</script>
RightNavigationDrawer.vue:
<template>
<v-navigation-drawer
v-model="open"
absolute
right>
</v-navigation-drawer>
</template>
<script>
export default {
name: 'RightNavigationDrawer',
props: {
open: false
}
}
</script>
【问题讨论】:
标签: javascript vue.js vue-component vuetify.js vue-props