【发布时间】:2019-02-27 02:35:18
【问题描述】:
我使用vue-property-decorator,这是一个简单的组件,但我收到了错误消息:
[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: "message"
这条消息是什么意思?我该如何解决这个问题?
这是我的代码示例:
<template>
<v-layout row justify-center>
<v-dialog v-model="dialog">........</v-dialog>
</v-layout>
</template>
<script lang="ts">
import { Component, Prop } from 'vue-property-decorator';
@Component({})
export default class SomeModal extends ... {
@Prop() public dialog?: boolean;
@Prop() public message?: string;
constructor() {
super();
}
public showError(er) {
this.message = er.message;
this.dialog = true;
}
}
</script>
<style scoped lang="scss">
</style>
【问题讨论】:
标签: javascript vue.js