twitter-bootstrap - 在 vue.js 条件后更改颜色

标签 twitter-bootstrap vue.js

当我使用这个脚本时:

<div class="card-content">
        <vue-tabs class="row" direction="vertical" value="Description">       
        <div v-for="(item, index) in siteObject.line_info" :key="index">
            <v-tab :title="siteObject.line_info[index].lineid">
                <div class="description text-left">
                    <small v-for="(field, key) in item" :key="key">
                        <strong>{{ key }}</strong> {{ field }}<br>
                    </small>
                </div>
            </v-tab>
        </div>        
      </vue-tabs>
      </div> 

我有这样的结果:

nsn 0102799121
上行 173.0-1/1
状态活跃
lex_id 78EFFEFVS
hdf_port
product_id PPS515818292
技术 VDSL
access_type BBCSNaked

如何显示状态 wen 是 active red 而 he inactive 是灰色?

最佳答案

您可能正在寻找条件类绑定(bind)。

https://v2.vuejs.org/v2/guide/class-and-style.html

<div class="static"
 v-bind:class="{ active: item.STATUS, 'text-danger': !item.Active}">
</div>

在您的情况下,我建议创建一个接收项目的函数。如果字符串 === ACTIVE 与否,则返回 true/false。像这样的东西:

<div class="static"
 v-bind:class="{ active: statusIsActiveFunction(item.STATUS), 'text-danger': !statusIsActiveFunction(item.STATUS)}">
</div>

关于twitter-bootstrap - 在 vue.js 条件后更改颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51086077/

相关文章:

html - 使用推/拉和 col-md-12 在 Bootstrap 4 中进行列排序

javascript - bootstrap slider /旋转木马如何在 div 上最大化?

vue.js - 从方法中只调用一个方法

vue.js - vue : escape and render HTML string?

javascript - Vue 3(组合API)获取数组长度

html - 如何在 Bootstrap 表行之间添加文本行?

html - 在 Bootstrap 面板标题中有一个输入栏的推荐方法吗?

html - 覆盖 Bootstrap .navbar 边框颜色

javascript - 将 Vuejs 单文件组件中的模板作为外部 HTML 文件导入

typescript - vuetify 中的 "TypeError: Cannot read property ' $路由器 ' of null"