JSFiddle - React, Tailwind, and code Playground
by imys
HTML
<div id="app">
<hello></hello>
</div>
JavaScript
var hello = {
template: `<div>
<button @click="onclick">click</button>
<p>{{text}}</p>
</div>`,
data() {
return {
text: ''
}
},
methods: {
onclick() {
this.$options = Vue.util.mergeOptions(this.$options, {
data() {
return { msg: 'hello' }
}
}, this)
console.log('click', this.msg)
this.text = this.msg
}
}
}
new Vue({
el: '#app',
components: { hello }
})