1.搭建环境:idea
2.v-bind绑定URL
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./js/vue.js"></script>
</head>
<body>
<!--
<div id="app">
<img v-bind:src="imgURL">
</div>
-->
<div id="app">
<img :src="imgURL">
</div>
<script>
var vm=new Vue({
el: "#app",
data:{
imgURL:'https://img.alicdn.com/imgextra/i2/26121140/O1CN01NfHQx71KIACWwdsQb_!!0-saturn_solar.jpg_468x468q75.jpg_.webp'
}
});
</script>
</body>
</html>
3.v-bind绑定class
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./js/vue.js"></script>
<style>
.active{
color: red;
}
</style>
</head>
<body>
<div id="app">
<!-- <h2 class="active">{{message}}</h2>-->
<!--<h2 v-bind:class="{key1:value1,key2:value2}">{{message}}</h2>-->
<!--<h2 v-bind:class="{类名1:bolean,类名2:bolean}">{{message}}</h2>-->
<!--<h2 :class="{active:true,line:false}">{{message}}</h2>-->
<h2 :class="{active:isactive,line:isline}">{{message}}</h2>
</div>
<script>
var vm=new Vue({
el: "#app",
data:{
message:"hello,vue",
isactive:true ,
isline: false
}
});
</script>
</body>
</html>
4.v-bind绑定style
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./js/vue.js"></script>
</head>
<body>
<div id="app">
<!--<h2 v-bind:style="{key(属性名):value(属性值)}">{{message}}</h2>-->
<!-- <h2>{{message}}</h2>-->
<h2 :style="{backgroundColor:finalcolor}">{{message}}</h2>
<h2 :style="{fontSize:finalsize+'px',backgroundColor:finalcolor}">{{message}}</h2>
</div>
<script>
var vm=new Vue({
el: "#app",
data:{
message:"hello,vue",
finalcolor: 'red',
finalsize:100
}
});
</script>
</body>
</html>