Vue的学习之class与style绑定

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Vue的学习</title>
		<script src="vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<!-- test是一个普通的css的样式 -->
			<!-- v-bind对class样式进行绑定,
			通过isActive来判断是否对样式的修饰 -->
			<!-- v-bind:class="{active:isActive,gree:isGree}" -->
			<!-- 第二种方式,也可以通过元组里面
			调用三目运算的方式进行修饰 -->
			<div class="test" v-bind:class="[isActive?'active':'',isGree?'gree':'']" style="width: 200px;height: 200px;
			text-align: center;line-height: 200px;">hi Vue</div>
			<br />
			<!-- 通过v-bin绑定style样式 -->
			<div :style="{color:color,fontSize:fontsize,
			background:isRed?'red':''}
			">hello Ryan</div>
		</div>

		<script type="text/javascript">
			var vm = new Vue({
				el: "#app",
				data: {
					isActive: true,
					isGree: true,
					color: "blue",
					fontsize: '30px',
					isRed: false,

				}
			});
		</script>

		<style type="text/css">
			.test {
				font-size: 30px;
			}

			.active {
				background: red;
			}

			.gree {
				color: green;
			}
		</style>
	</body>
</html>

本节对class与style的绑定内容就学习完毕了!!!

相关推荐

  1. Vue学习classstyle

    2024-07-11 22:44:03       22 阅读
  2. Class Style

    2024-07-11 22:44:03       58 阅读
  3. VueClassstyle方式

    2024-07-11 22:44:03       40 阅读
  4. Vue class样式

    2024-07-11 22:44:03       32 阅读
  5. vue动态class几种方法

    2024-07-11 22:44:03       35 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 22:44:03       70 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 22:44:03       74 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 22:44:03       62 阅读
  4. Python语言-面向对象

    2024-07-11 22:44:03       72 阅读

热门阅读

  1. day11:01文件处理

    2024-07-11 22:44:03       25 阅读
  2. C语言 会员卡计费系统

    2024-07-11 22:44:03       18 阅读
  3. RKNN3588——利用推理YOLOv8推理图片

    2024-07-11 22:44:03       18 阅读
  4. 如何使用thinkPHP3.2.* 版本开发

    2024-07-11 22:44:03       22 阅读
  5. EasyPOI与Apache POI

    2024-07-11 22:44:03       23 阅读
  6. Go 垃圾回收(GC)

    2024-07-11 22:44:03       24 阅读
  7. ccf认证 202312-3

    2024-07-11 22:44:03       24 阅读
  8. hid-ft260驱动学习笔记 5 - ft260_i2c_probe

    2024-07-11 22:44:03       23 阅读
  9. 使用Ultralytics YOLO进行模型验证

    2024-07-11 22:44:03       26 阅读