Last active
January 12, 2018 00:56
-
-
Save darrenjennings/ca3e75aa18c3cdb9a221126fe33eb2b3 to your computer and use it in GitHub Desktop.
Vue Render Prop - Child
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Mouse = { | |
name: "Mouse", | |
props: { | |
render: { | |
type: Function, | |
required: true | |
} | |
}, | |
data() { | |
return { | |
x: 0, | |
y: 0 | |
}; | |
}, | |
methods: { | |
handleMouseMove(event) { | |
this.x = event.clientX; | |
this.y = event.clientY; | |
} | |
}, | |
render(h) { | |
return ( | |
<div style={{ height: "100%" }} onMousemove={this.handleMouseMove}> | |
{this.$props.render(this)} | |
</div> | |
); | |
} | |
}; | |
export default Mouse; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment