013——VUE中多種方式使用VUE控制style樣式屬性


<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>多種方式使用VUE控制style樣式屬性</title>
		<script src="vue.js"></script>
	</head>
	<body>
		<!--使用變量或是字符串定義樣式屬性-->
		<div id="lantian">
			<h1 :style="{color:'red',fontSize:size+'px'}">美麗中國</h1>
			<h1 :style="{color:red,fontSize:'50px'}">美麗中國</h1>
			<hr />
			<input type="number" v-model="size" />
			<hr />
			<!--object變量定義-->
			<h2 :style="style">中國美麗</h2>
			
				
			<!--數組定義-->
			<h2 :style="[ltcms]">中國美麗</h2>
			
		</div>
		<script>
			var app=new Vue({
			el:'#lantian',
			data:{
				red:'green',
				size:20,
				style:{
					color:'blue',
					fontSize:'100px'
				},
				ltcms:{
					color:'#188eee',
					backgroundColor:'#999'
				}
			}
		});
		</script>
	</body>
</html>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM