JSFiddle - React, Tailwind, and code Playground
HTML
<div id="app">
<button @click="foo = 'bar'">
Change foo
</button>
{{foo}}
</div>
CSS
body {
color: #fff
}
JavaScript
new Vue({
el: '#app',
created() {
this.foo = 'foo'
},
mounted() {
this.applyFooWatcher()
},
methods: {
applyFooWatcher() {
this.$watch('foo', function(newVal, oldVal) {
console.log('Foo changed from ' + oldVal + ' to ' + newVal);
});
}
},
data: {
foo: ''
}
})