[英]Vue.js - How to use ternary operator to return html in vue with font awesome icons
I have the following in vue:我在 vue 中有以下内容:
<div class="pt-2">
<button
class="bg-gradient-to-r from-green-100 to-blue-100 rounded p-3 w-full text-xl font-medium focus:outline-none"
@click="isLoading = true"
:disabled="isLoading"
>
{{isLoading ? '<i class="fas fa-circle-notch fa-spin"></i>' :
'Register'}}
</button>
</div>
How would I get it to return the icon instead of showing:我如何让它返回图标而不是显示:
You should use conditional rendering using v-if
directive:您应该使用v-if
指令使用条件渲染:
<div class="pt-2">
<button
class="bg-gradient-to-r from-green-100 to-blue-100 rounded p-3 w-full text-xl font-medium focus:outline-none"
@click="isLoading = true"
:disabled="isLoading"
>
<i v-if="isLoading" class="fas fa-circle-notch fa-spin"></i>
<span v-else >Register</span
</button>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.