Skip to content

Instantly share code, notes, and snippets.

@upangka
Created December 30, 2019 08:52
Show Gist options
  • Save upangka/8e7ca458532dbbe2dac4d3612881572b to your computer and use it in GitHub Desktop.
Save upangka/8e7ca458532dbbe2dac4d3612881572b to your computer and use it in GitHub Desktop.
vue elementui el-dialog .sync 理解
<template>
<div>
<el-dialog
:title="data.title"
:width="width"
:visible.sync="data.visiable">
<span>测试</span>
</el-dialog>
</div>
</template>
<script>
export default {
props: {
data: {
type: Object
}
},
data () {
return {
width: '40%'
}
}
}
</script>
<ModifyData :data="modifyDialogData"></ModifyData>
data () {
return {
modifyDialogData: {
title: 'dialog',
visiable: true
}
}
@upangka
Copy link
Author

upangka commented Dec 30, 2019

关闭弹窗,居然影响到了父组件,没有报如下错误:

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: "visiable"

原因时传递的是一个对象,而改变的值时存储在对象里面的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment