Skip to content

Instantly share code, notes, and snippets.

@guendev
Created June 29, 2022 07:22
Show Gist options
  • Save guendev/3aeaac94273ba290110e06bdcd1e0bdc to your computer and use it in GitHub Desktop.
Save guendev/3aeaac94273ba290110e06bdcd1e0bdc to your computer and use it in GitHub Desktop.
import { defineComponent, h, reactive } from 'vue'
export default defineComponent({
name: 'VmButton',
setup() {
const state = reactive({
count: 0
})
const inc = () => {
state.count++
console.log('Update count: ', state.count)
}
return {
state,
inc
}
},
render() {
const result = h('span', [`Clicked ${this.state.count} times`])
return h(
'button',
{
onClick: this.inc,
class: 'btn btn-primary'
},
result
)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment