【发布时间】:2019-12-06 01:06:35
【问题描述】:
我正在使用 Vue、Nuxt 和 Element UI 构建 Web 应用程序。 我对元素对话框组件有疑问。 第一次可以打开,第二次不能打开。
这是关于我的问题的 GIF。
https://gyazo.com/dfca3db76c75dceddccade632feb808f
这是我的代码。
- index.vue
<template>
<div>
<el-button type="text" @click="handleDialogVisible">click to open the Dialog</el-button>
<modal-first :visible=visible></modal-first>
</div>
</template>
<script>
import ModalFirst from './../components/ModalFirst.vue'
export default {
components: {
'modal-first': ModalFirst
},
data() {
return {
visible: false,
};
},
methods: {
handleDialogVisible() {
this.visible = true;
}
}
}
</script>
- ModalFirst.vue
<template>
<el-dialog
title="Tips"
:visible.sync="visible"
width="30%"
>
<span>This is a message</span>
<span slot="footer" class="dialog-footer">
<a>Hello</a>
</span>
</el-dialog>
</template>
<script>
export default {
props: [ 'visible' ]
}
</script>
关闭对话框后,我可以在 google chrome 控制台上看到一条警告消息。 警告信息如下。
webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:620 [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: "visible"
found in
---> <ModalFirst> at components/ModalFirst.vue
<Pages/index.vue> at pages/index.vue
<Nuxt>
<Layouts/default.vue> at layouts/default.vue
<Root>
这是警告信息的截图。
【问题讨论】:
标签: vuejs2 nuxt.js element-ui