When passing parameters to the callback function in the parent component in the Vue sub-component, what if the callback function itself requires the parameter information of the parent component?

parent component declares function

methods: {
    edit(index, val) {
        console.log(index)
        console.log(val) //
    }
}

parent component calls child component to pass props

// editindex
<Child v-for="(item, index) in items" @editFn="edit(index)">

Sub-component trigger function

editHandler() {
    const value = "hello"
    this.$emit("editFn", value) //value
}
Jul.20,2021

< Child vmurfort = "(item, index) in items" @ editFn= "edit (index,arguments [0])" >. Thank Dajuan


it's a bit like whether a publish subscription integrates auto-snooping


1. The parent component can use .sync
2. You can v-on an event in the parent component to get the $emit of the child component


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