父组件传递数据给子组件 props里的属性不能在子组件中修改
问题:dialog对话框只能打开一次
子组件
<template>
<div>
<el-button @click="edit">编 辑</el-button>
<!-- Form -->
<el-dialog title="收货地址" :visible.sync="dialogFormVisible">
<el-form :model="form">
<el-form-item label="活动名称" :label-width="formLabelWidth">
<el-input v-model="form.name" autocomplete="off" />
</el-form-item>
<el-form-item label="活动区域" :label-width="formLabelWidth">
<el-select v-model="form.region" placeholder="请选择活动区域">
<el-option label="区域一" value="shanghai" />
<el-option label="区域二" value="beijing" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="confirm">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
props: {
dialogFormVisible: {
type: Boolean,
default: false
}
},
data() {
return {
form: {
name: '',
region: ''
},
formLabelWidth: '120px'
}
},
methods: {
cancel() {
this.$emit('cancel')
},
confirm() {
this.$emit('confirm')
},
edit() {
this.$emit('edit')
}
}
}
</script>
父组件
<template>
<div>
<insertDialog :dialog-form-visible="dialogFormVisible" @cancel="cancel" @confirm="confirm" @edit="edit"/>
</div>
</template>
<script>
import insertDialog from './moudle-binding-insert/insert-tableDialog'
export default {
components: {
insertDialog
},
data() {
return {
dialogFormVisible: false
}
},
methods: {
edit() {
this.dialogFormVisible = true
},
cancel() {
this.dialogFormVisible = false
},
confirm() {
this.dialogFormVisible = false
}
}
}
</script>
<style lang="scss" scoped>
.container {
display: flex;
justify-content: flex-start;
}
</style>
标签:false,edit,dialogFormVisible,在子,cancel,props,组件
From: https://blog.csdn.net/a1963919036/article/details/144509054