0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

element ui dialog を component にするとエラーが出る

0
Posted at

element ui。
子要素にダイアログを設定するとエラーが出る。


app.js:112146 [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: "visibleFlag"

found in

---> <TuuhouComponent> at resources/js/components/TuuhouComponent.vue
    <Question> at resources/js/components/Question.vue
        <Root>


ということで、エラーを回避するテンプレートを。

top.vue

<template>

    <div>
        <tuuhou-component :visible="visible" @onModal="onModal(false)"></tuuhou-component>
        <el-button type="primary" @click="onModal(true)">モーダル表示</el-button>
    </div>

</template>

<script>

    export default {
        components: {
            'tuuhou-component': () => import('./TuuhouComponent.vue')
        },
        data() {
            return {
               visible: false
            }
        },
        methods: {
            onModal(visible) {
                this.visible = visible
            },
            showModal() {
                this.$emit('onModal')
            }
        }

    }
</script>

tuuhouComponent.vue


<template>

    <div>
        <el-dialog
                :visible.sync="$props.visible"
                :before-close="hideModal"
        >
              <el-button type="info" @click="hideModal">閉じる</el-button>
        </el-dialog>
    </div>

</template>

<script>
    export default {
        props: {
            visible: {
                type: Boolean
            }
        },
        methods: {
            hideModal() {
                this.$emit('onModal')
            }
        }
    }
</script>



0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?