使用闭包传值
computed:{
checkHasError(){
// 使用闭包方式传值
return function(index,lang) {
if(this.wordList[index][lang] == '' && this.wordList[index].hasOwnProperty('hasError')){
return {
'has-error':true,
}
}
}
},
},
使用
<div class="form-group" v-bind:class="checkHasError(index,'form_word')">
<textarea v-bind:class="'form-control'" v-model="item.form_word" :placeholder="'请输入'+chineseLanguage(item.form_lang)"></textarea>
</div>