---
title: "Discussion on \"Watch 的情境使用\" | Hashnode"
description: "Discussion on \"Watch 的情境使用\". watch 總共有三個參數\n\nval : 第一個為 被監聽的變數\nnewVal : 當監聽數值變化時，產生的新數值\noldVal : 當監聽數值變化時，產生的舊數值\n\nwatch(val, (newVal, oldVal) => {\n    console.log(`new: ${newVal} ; old: ${oldVal}`);\n});\n\nref & reactive watch 監控差異\n下方範例測試簡單的 ref watch 範例來執行：\nconst { ref, reactive, ..."
url: "https://hashnode.com/posts/watch/63359ceefa20fa4bc8e539d1"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Watch 的情境使用](https://michael0520-blog.hashnode.dev/watch?utm_source=hashnode&utm_medium=feed)

watch 總共有三個參數 val : 第一個為 被監聽的變數 newVal : 當監聽數值變化時，產生的新數值 oldVal : 當監聽數值變化時，產生的舊數值 watch(val, (newVal, oldVal) => { console.log(\`new: ${newVal} ; old: ${oldVal}\`); }); ref & reactive watch 監控差異 下方範例測試簡單的 ref watch 範例來執行： const { ref, reactive, ...

Aug 13, 2022 · 3 min read · michael0520-blog.hashnode.dev  
Read the article

## Written by

[Michael Luo](https://hashnode.com/@Michael0520)

@Michael0520

  
[View profile](https://hashnode.com/@Michael0520)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
