Write the modal component of iview to the problem that cannot be opened by clicking on the subcomponent

I write the modal modal box into the child component, and the button of the parent component opens the mode box, which is written as follows:
the content of the parent component is:

<template>
    <div>
        <create-user :add-user-modal="addUserModal" @on-complete="complete">

        </create-user>
        <Card>
            <Button @click="addUserModal = true" type="primary" >{{ $t("add-user") }}</Button>
        </Card>
    </div>
</template>

<script>
    import createUser from "./components/create-user.vue"
    export default {
        components: {
            createUser
        },
        data () {
            return {
                addUserModal: false,
            }
        },
        methods: {
            complete (e) {
                this.addUserModal = e;
            }
        }
    }
</script>

the content of the subcomponent is:

<template>
    <Modal v-model="showModal">
        <p slot="header" style="text-align:center">
            <Icon type="person-add"></Icon>
            <span></span>
        

<div style="text-align:center"> // <div slot="footer"> <Button @click="close"></Button> <Button type="info" :loading="modal_loading" @click="addUser"></Button> </div> </div> </Modal> </template> <script> export default { name: "add-user-modal", props : { addUserModal : Boolean, }, data () { return { showModal: this.addUserModal, modal_loading: false, formItem: { jobNum: "", name: "", dept: "", email: "", phone: "" } } }, methods: { addUser () { let _this=this; _this.modal_loading = true; console.log(_this.formItem); setTimeout(() => { _this.modal_loading = false; _this.showModal = false; _this.$emit("on-complete",false); _this.$Message.success("Successfully delete"); }, 2000); }, close () { this.showModal = false; this.$emit("on-complete",!this.addUserModal); } }, mounted: function() { console.log(this.show) } } </script>

Click the parent component button, and the modal box does not appear

Oct.09,2021

you can change the value of showModal through watch addUserModal


sub-component showModal there is no update


your showModal is only initialized with the incoming addUserModal, and there is no bi-directional binding. If you modify addUserModal, it will not be changed to showModal.


Building owner, the v-model of the sub-component is changed to : value . For more information, please see Portal

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ba6a-2c2c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ba6a-2c2c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?