vue笔记02

:class="{textcolor:item.isTextColor}" <!-- class 绑定 -->
<template>
  <div id="app">
	<!-- v-text和v-html区别 -->
	<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>

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_36781179/article/details/82745051