:class="{textcolor:item.isTextColor}" <!-- class 绑定 -->
<template>
<div id="app">
<h1 v-text="title"></h1>
<h1 v-html="title1"></h1>
<ul>
<li v-for="item in items" :class="{textcolor:item.isTextColor}">
{{item.text}}
</li>
</ul>
</div>
</template>
<script>
export default {
name: 'App',
data: function () {
return {
title: 'this is a todo',
title1: '<p>this is a todo</p>',
items: [
{
text:'Hello',
isTextColor: false
},
{
text:'Hi',
isTextColor: true
}
]
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
.textcolor{
color:red;
}
</style>