为什么我们需要通过 'detail' 对象访问自定义事件属性?
function handleMessage(event) {
alert(event.detail.text); // why do we need to access 'text' property from 'detail' object?
}
// In the Child component, we are using this function to dispatch the custom event with some data.
function sayHello() {
dispatch('message', {
text: 'Hello!' // we are not wrapping the data into the 'detail' object
});
}