vue3 in element component emit pass event error
Report error:
Vue warn]: Extraneous non-emits event listeners (cancel, confirm, modelClose) 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.
Sub-component throwing events
emits: ['cancel', 'confirm', 'modelClose'],
setup (props, context) {
const { showDialog } = toRefs(props)
const show = computed(() => {
return showDialog.value
})
const cancel = () => {
context.emit('cancel')
}
const confirm = () => {
context.emit('confirm')
}
const modelClose = () => {
context.emit('modelClose')
}
return {
show, cancel, confirm, modelClose
}
Parent component receives events
`<user-info :showDialog="showDialog" @cancel="showDialog=false" @confirm="showDialog=false" @modelClose="showDialog=false"></user-info>
Read More:
- Vue element component V-for error [How to Modify)
- [Solved] Vue3.0 Error: The component has been registered but not used vue/no-unused-components, Close eslint
- [Solved] vue error: error Component name “School“ should always be multi-word vue/multi-word-component-names
- Vue3.0 error: Failed to resolve component el-form-item (el element to be unable to be displayed)
- Vue project change directory run error:Multiple assets emit different content to the same filename index.html
- Vue Error: component has been registered but not used [Two Methods to Solve]
- Vue Import element-plus Error: Failed to resolve import “element-pluslibtheme-chalkindex.css“ from “src
- Vue wran name Error: Unkown custom element [How to Solve]
- [Solved] Vue3.2 component computed Error: Write operation failed: computed value is readonly
- [Solved] Vue3 Error: Failed to resolve component:xxx
- [Solved] Vue eslint Error: Component name “*****“ should always be multi-word
- [Solved] vue3vite Error: Failed to resolve import “@vue/server-renderer from “src\App.vue“. Does the file exist
- Vue3 + vite install element-plus error [How to Solve]
- How to Solve Vue add element Install Error
- [Solved] Vue3 Import element UI error: Uncaught TypeError: Cannot read properties of underfined…
- Vue3 Error: [vue/no-multiple-template-root] The template root requires exactly one element
- Front end initialization Vue element admin error [How to Solve]
- 9:13 error Component name “home“ should always be multi-word vue/multi-word-component-names
- [Solved] Vue Element Date plug-in reports an error in form validation
- [Solved] vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click“: “TypeError: Cannot read property