【发布时间】:2023-02-10 15:07:18
【问题描述】:
我有一对按钮,必须根据我从 API 获得的响应进行切换。
我为此使用的代码
<div class="small-7 column btn-switch">
<span class="switch-statement">"Is it mandatory"</span>
<button
:class="!isMandatory ? 'button--secondary' : 'button--tertiary'"
class="button button-border"
@click="setMandatory(false)"
>
"No"
</button>
<button
:class="isMandatory ? 'button--secondary' : 'button--tertiary'"
class="button"
role=`your text`"button"
@click="setisMandatory(true)"
>
"Yes"
</button>
</div>
我尝试对按钮使用 v-if,但正如我所料,它没有用。有没有其他方法可以做到这一点?
【问题讨论】:
标签: javascript vue.js frontend