<!DOCTYPE html>
<div id="app">
{{ state.count }}
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const app = Vue.createApp({});
const { reactive, watchEffect} = Vue;
const state = reactive({
count:0
})
watchEffect(() => {
document.body.innerHTML = `count is ${state.count}`
}).mount('#app')
</script>
改:
<!DOCTYPE html>
<div id="app">
{{ state.count }}
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
const app = Vue.createApp({});
const { reactive, watchEffect} = Vue;
const state = reactive({
count:0
})
watchEffect(() => {
document.body.innerHTML = `count is ${state.count}`
})
</script>