gua214.html:16 Uncaught TypeError: watchEffect(...).mount is not a function

<!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>
上一篇:前端面试 手写代码篇


下一篇:学院信息维护-查询学院信息03