Skip to content

The object syntax for events doesn't work in the render function(h()) #2227

@waantony

Description

@waantony

Version

3.0.0

Reproduction link

https://codepen.io/waantony/pen/BaKMbxr

Steps to reproduce

Click the button and nothing happened.

<!DOCTYPE html>
<html>
<head>
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@3.0.0/dist/vue.global.js"></script>
</head>
<body>
  <div id="app"></div>

  <script>
    const { h, createApp } = Vue
    createApp({
      render () {
        return h('button', {
          // This is OK!
          // onClick: () => {
          //   console.log('onClick', 'OK')
          // },

          // This doesn't work!
          onClick: {
            handler () {
              console.log('onClick', 'OK')
            },
          },
        }, 'click')
      },
    }).mount('#app')
  </script>
</body>
</html>

What is expected?

The object syntax for events works in the render function.

What is actually happening?

It doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions