Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vuejs2 如何使用Vuejs 2连接文本类_Vuejs2 - Fatal编程技术网

Vuejs2 如何使用Vuejs 2连接文本类

Vuejs2 如何使用Vuejs 2连接文本类,vuejs2,Vuejs2,如何使用vuejs 2动态连接文本 以下是我现在拥有的: <span class="label" :class="label-{{account.Segment}}">{{account.Segment}}</span> {{account.Segment} 科目.段==“ABC” 我需要的是 <span class="label label-ABC">ABC</span> ABC 这里有一种可能的方法 <span class="lab

如何使用vuejs 2动态连接文本

以下是我现在拥有的:

<span class="label" :class="label-{{account.Segment}}">{{account.Segment}}</span>
{{account.Segment}
科目.段==“ABC”

我需要的是

<span class="label label-ABC">ABC</span>
ABC

这里有一种可能的方法

<span class="label" :class="'label-' + account.Segment">{{account.Segment}}</span>
{{account.Segment}

您可以使用字符串数组添加更多类

computed: {
  classNames() {
    // add more logic here
    let classNames = ['label'];
    classNames.push(`label-${this.contextType}`);
    return classNames;
  },
},
然后你可以像这样使用它

<div :class="classNames">
...
</div>

...