-
Hi, <div x-data="{
sum_of_items: 0,
get is_valid_sum_of_items() {
return this.sum_of_items === 100
}
}">
<div x-show="is_valid_sum_of_items">
This block work correctly depending on value of `sum_of_items` in `x-data`
</div>
<div :class="is_valid_sum_of_items ? 'text-valid-green' : 'text-invalid-red'">
This block has a problem. `is_valid_sum_of_items` getter does not invoked I guess `undefined`. So
</div>
<div :class="sum_of_items === 100 ? 'text-valid-green' : 'text-invalid-red'">
This is a workaround. Direct use of property is totally working its way.
</div>
</div> This is a kind of silly example because there is no reason to use getter. Many thanks in advance!! |
Beta Was this translation helpful? Give feedback.
Answered by
capymind
Mar 29, 2023
Replies: 1 comment
-
Sorry.... This is 100% my fault. The code above work correctly... Original wrong code snippet is below.. <div :class="is_valid_sum_of_items === 100 ? 'text-valid-green' : 'text-invalid-red'">
This block has a problem. `is_valid_sum_of_items` getter does not invoked I guess `undefined`. So
</div>
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
capymind
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry.... This is 100% my fault. The code above work correctly...
Original wrong code snippet is below..
is_valid_sum_of_items
getter already returntrue
orfalse
based on propertysum_of_items
inx-data
. sois_valid_sum_of_items === 100
istrue === 100
orfalse === 100
. :(