(自用)03-v-bind动态绑定元素的属性

01-v-bind基本应用

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="UTF-8"></script>
		<style type="text/css">
		.abc{color: aquamarine;font-size: 20px;}
		
		
		</style>
	</head>
	<body>
		<div id="app">
			<h1>1 动态绑定style属性的值:</h1>
			<h2 v-bind:style="str">{{msg}}</h2>
			<h1>2 动态绑定src属性的值</h1>
			<img v-bind:src="imgsrc" v-bind:style="imgstyle">
			<ul>
				<li v-bind:style="ulstyle" v-for="item in movies">{{item}}</li>
			</ul>
			<h1>3 动态绑定href的属性值:</h1>
			<a :href="bili">B站</a>
		</div>
		
		<script type="text/javascript">
		const app=new Vue({
			el:"#app",
			data:{
				msg:"我是xxxxx",
				str:'color: aquamarine;font-size: 20px;',
				imgsrc:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg2.doubanio.com%2Fview%2Frichtext%2Flarge%2Fpublic%2Fp196257303.jpg&refer=http%3A%2F%2Fimg2.doubanio.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1649754665&t=d89518826168d0a4254732d18cb6c9af',
				imgstyle:'width:800px; height:600px; border:5px solid yellow',
				movies:['西游记','大话西游','123','456'],
				ulstyle:'color:#ff00cc',
				bili:'https://www.bilibili.com/'
			}
		})
		</script>
	</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值