the reviewer's identity is private. Once this is working I will add v-if-else">
Firestore database fields (reviewPrivacy
fields in the "review" collection) are of type string, populated by Vue form inputs (radio buttons), with three possible answers (values) One is keepFullyPrivate
.
If the value of review.reviewPrivacy
is keepFullyPrivate
, I want to show that
. the reviewer's identity is private< /h2>
Once this is working, I will add the v-if-else
and v-else
options to display different content for each option.
My code is as follows.
No errors are flagged in VSC, but the text in the tag always appears no matter what the value of
review.reviewPrivacy
, regardless of whether it is equal to keepFullyPrivate
.
Commenter's identity is private
Update (additional information):
Privacy choices for this review: {{ review.reviewPrivacy }}
in the DOM Display the following text: Privacy choices for this comment: postAnonPublic, which is a v-else-if
condition. Second update: As requested in the comments, make the code a complete block:
Privacy choices for this review: {{ review.reviewPrivacy }}
The reviewer's identity is private
Anonymous - Reviewer: {{ review.userName }} h2>
Reviewer chose full disclosure - full name {{ review.userFirstName }} {{ review.userLastName }}
Created {{ review.createdAt }} days ago
Thank you!
('review.reviewPrivacy', '==', 'keepFullyPrivate')
is just a set of comma-separated strings, and its value is the last string:'keepFullyPrivate '
, so your tag becomesv-if="'keepFullyPrivate'"
, which is always true. Therefore,div
and itsh2
will always be rendered.The correct expression to compare
review.reviewPrivacy
and'keepFullyPrivate'
is:It is a good practice to use three equal signs (
====
) forstrict comparison.Therefore, the final result should be: