I want to display class of a div depends on the state of isAddingVarian
or isEditingVarian
if both of them is true the class will be float-right d-one
and if false it will be float-right
. i know i can do like this
<div class={isAddingVarian || isEditingVarian?'float-right d-none':'float-right'}>
but i want something like this
<div class={"float-right "+isAddingVarian || isEditingVarian?"d-none":''}>
how can i do that?
尝试这个
<div className={`float-right ${isAddingVarian || isEditingVarian? "d-none":''} `}></div>
The way you have it set up you will never make it to your ternary expression, a string containing chars will always be true, and the || operator returns the first true value.
You just need to rethink the logic and set it up differently.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.