JavaScript/vue.js/watch:修订间差异
来自康健生活
| 第1行: | 第1行: | ||
== VUE 3 == | == VUE 3 == | ||
=== 多参数监听 === | |||
<syntaxhighlight lang="html"> | <syntaxhighlight lang="html"> | ||
<script setup> | <script setup> | ||
| 第9行: | 第11行: | ||
} | } | ||
) | ) | ||
</script></syntaxhighlight> | |||
=== 停止监听 === | |||
<syntaxhighlight lang="html"> | |||
<script> | |||
export default defineComponent({ | |||
// ... | |||
watch: { | |||
foo(_new, _old) { | |||
// ... | |||
} | |||
}, | |||
setup(props, vm) { | |||
// ... | |||
vm.$watch("count")(); | |||
} | |||
// ... | |||
}) | |||
</script></syntaxhighlight> | </script></syntaxhighlight> | ||