How do the child components of a Vue dynamic component pass values to the parent component?

RT, I need to load different components according to the parameters of the page. The component contains the form data. Logically, I emit the data in the child component back to the parent component, and the parent component listens to the data returned by the component, but it doesn"t seem to work. The data can"t be printed. I don"t know what"s wrong. Ask the boss for help.

attach the code, which is the parent component:

<template>
    <div class="approvals-create-page p-4">
        <div class="card">
            <div class="card-body">
                <div class="mx-auto">
                    <component :is="component" 
                        v-on:form-data="handleFormData">
                    </component>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import leave from "./forms/_leave";

export default {
    components: {
        leave
    },
    created () {
        let currentPageType = this.$route.params.type;
        this.component = currentPageType ? currentPageType : "leave";
    },
    data () {
        return {
            component: "",
            form: {
                fields: {},
                reviewer: [],
                cc: []
            }
        }
    },
    methods: {
        // 
        handleFormData (data) {
            this.form.fields = data;
            console.log(this.form);
        }
    }
}
</script>

this is a subcomponent:

<script>
    export default {
        data() {
            return {
                form: {
                    name: "",
                    region: "",
                    date1: "",
                    date2: "",
                    delivery: false,
                    type: [],
                    resource: "",
                    desc: ""
                }
            }
        },
        methods: {
            onSubmit() {
                this.$emit("formData", this.form);
            }
        }
    }
</script>
May.06,2021

the child component is not registered with the parent component


Change

to

<component :is="component" 
    v-on:formData="handleFormData">
</component>

Hump-turned-to-short horizontal line segmentation scene:

when defining a component using PascalCase (hump naming), you can use both naming methods when referencing this custom element. That is to say, < my-component-name > and < MyComponentName > are both acceptable
The feature names in
HTML are case-insensitive, so the browser interprets all uppercase characters as lowercase characters. This means that when you use the template in DOM, the prop name of the, camelCase (hump nomenclature needs to be named with its equivalent kebab-case (dash separated naming):
Vue.component('blog-post', {
  //  JavaScript  camelCase 
  props: ['postTitle'],
  template: '<h3>{{ postTitle }}</h3>'
})
<!--  HTML  kebab-case  -->
<blog-post post-title="hello!"></blog-post>

Don't make a mess


excuse me, I have such a requirement: add child components dynamically after the button in the parent component is clicked. There are various forms in this child component. I change the data in the child component form, and then submit the data by the submit button in the parent component. The question now is, after the data is changed in the child component, how do you get it from the parent component? I know that events are triggered in the child component, and then can be heard through the $emit, and then in the parent component. But now changing the data in the child component is committed by the parent component, that is, no event is triggered in the child component. How can this be achieved? Ask the boss for advice

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-1eae952-46f2b.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-1eae952-46f2b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?