<h3 dir="auto">What problem does this feature solve?</h3>
<p dir="auto">?.语法已经成为ES2020标准，希望模版编译引擎尽快支持</p>
<h3 dir="auto">What does the proposed API look like?</h3>
<p dir="auto">v-if="data?.sub?.id"</p>
<h3 dir="auto">Version</h3>
<p dir="auto">2.5.16</p>
<h3 dir="auto">Reproduction link</h3>
<p dir="auto"><a href="https://jsfiddle.net/eywraw8t/193744/" rel="nofollow">https://jsfiddle.net/eywraw8t/193744/</a></p>
<h3 dir="auto">Steps to reproduce</h3>
<ul dir="auto">
<li>Create some data A and computed props B and C</li>
<li>Let C depend on B, and B depend on A. Set it up so the value of B should change less often than A</li>
<li>Then modify A</li>
</ul>
<h3 dir="auto">What is expected?</h3>
<p dir="auto">The value of C should only be re-computed when the value of B changes, independent of how often A is changing.</p>
<h3 dir="auto">What is actually happening?</h3>
<p dir="auto">The value of C is re-computed whenever A changes. This results in many extra re-computations.</p>
<hr>
<p dir="auto"><a href="https://vuejs.org/v2/guide/computed.html#Computed-Caching-vs-Methods" rel="nofollow">The docs say</a>:</p>
<blockquote>
<p dir="auto">A computed property will only re-evaluate when some of its dependencies have changed.</p>
</blockquote>
<p dir="auto">In this case, I thought there was a bug in my code because certain threshold-based computed properties were triggering re-computes far more often than expected, and some of these re-computes were fairly expensive.</p>
<p dir="auto">Perhaps is expected behavior? However it was surprising to me, and negates a lot of the potential for cache-based optimization when leveraging computed props.</p>
<p dir="auto">Compare to this implementation that uses watchers and extra data, but works as expected:</p>
<p dir="auto"><a href="https://jsfiddle.net/eywraw8t/193746/" rel="nofollow">https://jsfiddle.net/eywraw8t/193746/</a></p>
<p dir="auto">Here, C is only recomputed when B changes - not whenever A changes.</p>