{"id":1017,"date":"2023-03-12T09:27:53","date_gmt":"2023-03-12T01:27:53","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1017"},"modified":"2023-04-29T13:15:24","modified_gmt":"2023-04-29T05:15:24","slug":"vue-2-watch-option-handler-deep-immediate","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/vue-2-watch-option-handler-deep-immediate\/","title":{"rendered":"Vue2.0 watch\u9009\u9879 handler deep immediate"},"content":{"rendered":"<ul>\n<li>deep\uff1a\u9ed8\u8ba4\u503c\u662ffalse\uff0c\u4ee3\u8868\u662f\u5426\u6df1\u5ea6\u76d1\u542c\u3002<\/li>\n<li>immediate\uff1atrue\u4ee3\u8868\u5982\u679c\u5728wacth\u91cc\u58f0\u660e\u4e86\u4e4b\u540e\uff0c\u5c31\u4f1a\u7acb\u5373\u5148\u53bb\u6267\u884c\u91cc\u9762\u7684handler\u65b9\u6cd5\uff0c\u5982\u679c\u4e3afalse\u5219\u9ed8\u8ba4\u5728\u6570\u636e\u66f4\u65b0\u65f6\u6267\u884chandler\u65b9\u6cd5\uff0c\u4e0d\u4f1a\u5728\u7ed1\u5b9a\u7684\u65f6\u5019\u5c31\u6267\u884c\u3002<\/li>\n<\/ul>\n<p><!-- more --><\/p>\n<pre><code class=\"language-javascript\">watch: {\n  a: function (val, oldVal) {\n    console.log(&#039;new a: %s, old: %s&#039;, val, oldVal)\n  },\n  \/\/ \u65b9\u6cd5\u540d\n  b: &#039;someMethod&#039;,\n  \/\/ \u6df1\u5ea6 watcher\n  c: {\n    handler: function (val, oldVal) {\n      console.log(&#039;new c: %s, old: %s&#039;, val, oldVal)\n    },\n    deep: true\n  },\n  \/\/ \u8be5\u56de\u8c03\u5c06\u4f1a\u5728\u4fa6\u542c\u5f00\u59cb\u4e4b\u540e\u88ab\u7acb\u5373\u8c03\u7528\n  d: {\n    handler: function (val, oldVal) {\n      console.log(&#039;new d: %s, old: %s&#039;, val, oldVal)\n    },\n    immediate: true\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>deep\uff1a\u9ed8\u8ba4\u503c\u662ffalse\uff0c\u4ee3\u8868\u662f\u5426\u6df1\u5ea6\u76d1\u542c\u3002 immediate\uff1atrue\u4ee3\u8868\u5982\u679c\u5728wacth\u91cc\u58f0\u660e\u4e86\u4e4b\u540e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-1017","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1017"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1017\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}