1. v-bind:class(根据需求进行选择)

<style>
.box{
background-color: #ff0;
}
.textColor{
color: #000;
}
.textSize{
font-size: 30px;
}
</style> <div id="app">
<span class="box" :class="{'textColor':isColor, 'textSize':isSize}">我是字</span>
</div> <script>
  new Vue({
  el: "#app",
  data:{
  isColor:true,
  isSize:true
  }
  })
</script> 方法1

1.1

<style>
.box{
background-color: #ff0;
}
.textColor{
color: #000;
}
.textSize{
font-size: 30px;
}
</style>
<div id="app">
<span class="box" :class="classObject">我是字</span>
</div>
<script>
new Vue({
el: "#app",
data:{
classObject:{
'textColor': true,
'textSize': true
}
}
})
</script> 方法2

1.2

<style>
.box{
background-color: #ff0;
}
.textColor{
color: #0f0;
}
.textSize{
font-size: 30px;
}
</style>
<div id="app">
<span class="box" :class="[classA,classB]">我是字</span>
</div>
<script>
new Vue({
el: "#app",
data:{
classA: 'textColor',
classB: 'textSize'
}
})
</script>

1.3

<style>
.box{
background-color: #ff0;
}
.textColor{
color: #0f0;
}
.textSize{
font-size: 30px;
}
</style>
<div id="app">
<span class="box" :class="[isA?classA:'', classB]">我是字</span>
</div>
<script>
new Vue({
el: "#app",
data:{
classA: 'textColor',
classB: 'textSize',
isA: false
}
})
</script>

1.4

2.v-bind:style (根据需求进行选择,驼峰式)

<div id="app">
<span class="box" :style="{color:activeColor, fontSize:size,textShadow:shadow}">我是字</span>
</div>
<script>
new Vue({
el: "#app",
data:{
activeColor: 'red',
size: '30px',
shadow: '5px 2px 6px #000'
}
})
</script>

2.1

<div id="app">
<span class="box" :style="styleObject">我是字</span>
</div>
<script>
new Vue({
el: "#app",
data:{
styleObject:{
color: 'red',
fontSize: '30px',
textShadow: '5px 2px 6px #000'
}
}
})
</script>

2.2

<div id="app">
<span class="box" :style="[styleA,styleB]">我是字</span>
</div>
<script>
new Vue({
el: "#app",
data:{
styleA:{
fontSize: '30px',
color: 'red'
},
styleB:{
textShadow: '5px 2px 6px #000'
}
}
})
</script> 2.3

2.3

<div id="app">
<span class="box" :style="[isA?styleA:'', styleB]">我是字</span>
</div>
<script>
new Vue({
el: "#app",
data:{
styleA:{
fontSize: '30px',
color: 'red'
},
styleB:{
textShadow: '5px 2px 6px #000'
},
isA: false
}
})
</script> 2.4

2.4

3.v-bind:src

<div id="app">
<img :src="url" />
</div>
<script>
new Vue({
el: "#app",
data:{
url: "../img/pg.png"
}
})
</script>

3.1

4.v-bind:title

<div id="app">
<div :title="message">我是字</div>
</div>
<script type="text/javascript">
new Vue({
el: "#app",
data:{
message:"我是吱吱"
}
})
</script>

4.1

v-bind:的基本用法的更多相关文章

  1. MyBatis从入门到精通(第4章):MyBatis动态SQL【foreach、bind、OGNL用法】

    (第4章):MyBatis动态SQL[foreach.bind.OGNL用法] 4.4 foreach 用法 SQL 语句中有时会使用 IN 关键字,例如 id in (1,2,3).可以使用 ${i ...

  2. js中.bind()和.call()用法讲解

    var option = { ti : 8, it(){ return this.ti; } } 这里又一个option对象,it()方法里的this指的就是option对象的上下文. console ...

  3. 一个简单的例子让你很轻松地明白JavaScript中apply、call、bind三者的用法及区别

    JavaScript中apply.call.bind三者的用法及区别 引言 正文 一.apply.call.bind的共同用法 二. apply 三. call 四. bind 五.其他应用场景 六. ...

  4. C语言中 v...printf类函数的用法

    C语言的自学渐渐接近尾声,今天学到了标准库中的stdarg.h头,里面关联了stdio.h头里面的一类函数:v...printf函数,里面举的例子看了之后还是不太明白,google了一下依旧不是很懂, ...

  5. apply、call、bind区别、用法

    apply和call都是为了改变某个函数运行时的上下文而存在的(就是为了改变函数内部this的指向):   如果使用apply或call方法,那么this指向他们的第一个参数,apply的第二个参数是 ...

  6. MyBatis bind标签的用法

    From<MyBatis从入门到精通> <!-- 4.5 bind用法 bind标签可以使用OGNL表达式创建一个变量并将其绑定到上下文中. 需求: concat函数连接字符串,在M ...

  7. js中call,apply,bind方法的用法

    call .apply.和bind 以上这三个方法都是js function函数当中自带的方法,用来改变当前函数this的指向. call()方法 语法格式: fun.call(thisArg[,ar ...

  8. C++11 bind和function用法

    function是一个template,定义于头文件functional中.通过function<int(int, int)> 声明一个function类型,它是“接受两个int参数.返回 ...

  9. call(),apply(),bind() 区别和用法

    call call 方法第一个参数是要绑定给this的值,后面传入的是一个参数列表.当第一个参数为null.undefined的时候,默认指向window. var arr = [1, 2, 3, 8 ...

  10. C++11 中的function和bind、lambda用法

    std::function 1. std::bind绑定一个成员函数 #include <iostream> #include <functional> struct Foo ...

随机推荐

  1. MVVMLight - Messenger 2

    本篇介绍MvvmLight中一个重要的东东,那就是Messenger. (一)Messenger的基本组成 Messenger类用于应用程序的通信,接受者只能接受注册的消息类型,另外目标类型可以被指定 ...

  2. JS实现图片预览与等比缩放

    案例仅为图片预览功能,省略图片上传步骤,框架为easyui. HTML代码: @*text-align:center;水平居中 vertical-align: middle;display: tabl ...

  3. vue 报错./lib/html5-entities.js, this relative module was not found

    今天在做项目一直都挺正常的,我稍微休息一下回来就报这个错,我百度了半天也没找到答案.然后我只能重新安装vue-cli,奇迹发生了错误没有,然后我又休息了一会发现有报错了.气炸了都. 话不多多说直接上图 ...

  4. C#基础:传入URL,获得Http Post

    #region 传入url,获得Http Post public string HttpGet(string url) { string result = string.Empty; try { va ...

  5. 一、URL和URLConnection

    一.简述: 在Java网络编程中,我们最常听到的一个单词是URL.URL标识了一个资源,并可以通过URL来获取这个资源.我们不知道资源具体是什么,也不需要关心怎么获取.你只需要拿到一个URL,你就可以 ...

  6. 流畅的python和cookbook学习笔记(一)

    1.数据结构 1.1 内置序列类型 四种序列类型: 1.容器序列:list.tuple和collections.deque 2.扁平序列:str.bytes.bytearray.memoryview和 ...

  7. 使用 WireShark 分析 TCP/IP 三次握手 和 四次挥手

    TCP 三次握手 示意图 Wireshark 抓包注意事项 为了演示一个TCP三次握手建立连接的过程,我们通过 Chrome 访问一个网页. 已知 HTTP 协议就是建立在TCP链接上的 比如访问以下 ...

  8. 四层协议和Socket编程

    <四层协议图> <Soclet编程模型图>

  9. javascript获取元素样式值

    使用css控制页面有4种方式,分别为行内样式(内联样式).内嵌式.链接式.导入式. 行内样式(内联样式)即写在html标签中的style属性中,如<div style="width:1 ...

  10. jquery each() 方法跳出循环

    1.jquery each() 方法  return false: 的时候  相当于  break; 跳出整个循环: 2.jquery each() 方法  return true: 的时候  相当于 ...