Subscribe on changes!

when dispatch CustomEvent will be Maximum call stack size exceeded

avatar
Sep 26th 2022

Here is the correct usage:

// App.vue
<script setup>
import { ref } from 'vue'

import Comp from "./Comp.vue"
  
const msg = ref('Hello World!')
const onRenderClick = e=>{
  console.log(1)
}
</script>

<template>
  <div>
    <Comp @renderClick="onRenderClick"/>
  </div>
</template>
// Comp.vue
<script setup>
import { ref } from 'vue'

const click = e=>{
  e.target.dispatchEvent(new CustomEvent('render-click', {
    bubbles: true,
    detail: {
    demo:'click'
    }
  }))
}
</script>

<template>
  <div style="background:red;color:#ffffff" @click="click">
     click me
  </div>
</template>