vue系列教程第五篇,即绑定设置属性的多种方式,具体内容如下
一、设置属性的值: {{data中的数据}}
window.onload = function () {
var c = new Vue({
el : '#box',
data : {
url : 'https://www.easck.com/d/file/200614/20200614055541146.jpg'
}
});
}
<div id="box">
<img src="{{url}}" alt=""/>
</div>
二、v-bind绑定属性的值
window.onload = function () {
var c = new Vue({
el : '#box',
data : {
url : 'https://www.easck.com/d/file/200614/20200614055541146.jpg'
}
});
}<div id="box">
<img v-bind:src="url" alt=""/>
</div>
三、简写方式,冒号 (:) 绑定
window.onload = function () {
var c = new Vue({
el : '#box',
data : {
url : 'https://www.easck.com/d/file/200614/20200614055541146.jpg'
}
});
}
<div id="box">
<img :src="url" alt=""/>
</div>四、绑定多个属性
window.onload = function () {
var c = new Vue({
el : '#box',
data : {
url : 'https://www.easck.com/d/file/200614/20200614055541146.jpg',
w : '400px',
t : '这是一张百度图片'
}
});
}
<div id="box">
<img :src="url" :width="w" :title="t" alt=""/>
</div>










