The following warning is reported in component communication (child to parent) in Vue3.
[Vue warn]: Extraneous non-emits event listeners (changeParentProps) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the “emits” option.
Solution: Just declare the custom event name
emits: [‘changeParentProps’]
<template>
<div>
Subcomponents
</div>
<button @click="changeParentProps"> Changes the parent component's passed props</button>
</template>
<script lang="ts">
import { defineComponent } from '@vue/composition-api'
export default defineComponent({
emits: ['changeParentProps'],
props: {
data: {
type: String,
default: ''
}
},
setup (props, { emit }) {
// console.log(props)
const changeParentProps = () => {
emit('changeParentProps', '123')
}
return {
changeParentProps
}
}
})
</script>
Read More:
- [Solved] Vue Error: Failed to mount component: template or render function not defined
- [Solved] error Component name “index“ should always be multi-word vue/multi-word-component-names
- Vue Error compiling template: Component template should contain exactly one root element. If you
- [Solved] kubeflow pipeline visualization component Error: WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager…
- Tensorflow Error polling for event status: failed to query event: CUDA_ERROR_ILLEGAL_ADDRESS
- How to Fix the common Warning Errors after Vue Project Startup
- [Solved] element-plus Error: Failed to resolve component
- TypeError: unsupported format string passed to numpy.ndarray.__format__
- Unknown custom element: [xxx] – did you register the component correctly…
- ValueError: Input 0 of node import/save/Assign was passed float from import/beta1_power:0 incompatib
- [Sp;ved] Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ssm]
- [Solved] error: ‘xcb_generic_event_t’ was not declared in this scope
- Tomcat startup error: Failed to start component [StandardServer[8005]] solution
- Ant Design Vue-Table Error: warning.js?2149:7 [How to Solve]
- Solve the data transfer between vue irrelevant components error: this.$store.commit is not a function
- [Solved] Rtthread DCM component dcm_cache_save interface Error: mkdir:/data failed
- [Solved] Event Log Error: Failed to retrieve application JMX service URL
- [Solved] Warning: using directive refers to implicitly-defined namespace ‘std’
- [How to Solve Vue warn]: Unknown custom element: did you register the component correctly?
- [Go] Testing when solving go test: warning: no tests to run