If I in vue have an expression like
{{foo.earlier_versions.length}}
... the page is emitting an error if foo
or foo.earlier_versions
is undefined, but angularjs (if I had used that) would be more relaxed and just give us an empty result.
The error I get is like
and the page execution is terminated.
Is there a way to have vue equally forgiving?
It would really help to not have to write long expressions just to make them "correct".
CodePudding user response:
if you have all the recent dependencies/ devDependencies you can use this
<span class="ml-5 font-bold">
{{ foo?.earlier_versions?.length ?? 'fallback value' }}
</span>