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

  1. <style>
  2. .box{
  3. background-color: #ff0;
  4. }
  5. .textColor{
  6. color: #000;
  7. }
  8. .textSize{
  9. font-size: 30px;
  10. }
  11. </style>
  12.  
  13. <div id="app">
  14. <span class="box" :class="{'textColor':isColor, 'textSize':isSize}">我是字</span>
  15. </div>
  16.  
  17. <script>
  18.   new Vue({
  19.   el: "#app",
  20.   data:{
  21.   isColor:true,
  22.   isSize:true
  23.   }
  24.   })
  25. </script>
  26.  
  27. 方法1

1.1

  1. <style>
  2. .box{
  3. background-color: #ff0;
  4. }
  5. .textColor{
  6. color: #000;
  7. }
  8. .textSize{
  9. font-size: 30px;
  10. }
  11. </style>
  12. <div id="app">
  13. <span class="box" :class="classObject">我是字</span>
  14. </div>
  15. <script>
  16. new Vue({
  17. el: "#app",
  18. data:{
  19. classObject:{
  20. 'textColor': true,
  21. 'textSize': true
  22. }
  23. }
  24. })
  25. </script>
  26.  
  27. 方法2

1.2

  1. <style>
  2. .box{
  3. background-color: #ff0;
  4. }
  5. .textColor{
  6. color: #0f0;
  7. }
  8. .textSize{
  9. font-size: 30px;
  10. }
  11. </style>
  12. <div id="app">
  13. <span class="box" :class="[classA,classB]">我是字</span>
  14. </div>
  15. <script>
  16. new Vue({
  17. el: "#app",
  18. data:{
  19. classA: 'textColor',
  20. classB: 'textSize'
  21. }
  22. })
  23. </script>

1.3

  1. <style>
  2. .box{
  3. background-color: #ff0;
  4. }
  5. .textColor{
  6. color: #0f0;
  7. }
  8. .textSize{
  9. font-size: 30px;
  10. }
  11. </style>
  12. <div id="app">
  13. <span class="box" :class="[isA?classA:'', classB]">我是字</span>
  14. </div>
  15. <script>
  16. new Vue({
  17. el: "#app",
  18. data:{
  19. classA: 'textColor',
  20. classB: 'textSize',
  21. isA: false
  22. }
  23. })
  24. </script>

1.4

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

  1. <div id="app">
  2. <span class="box" :style="{color:activeColor, fontSize:size,textShadow:shadow}">我是字</span>
  3. </div>
  4. <script>
  5. new Vue({
  6. el: "#app",
  7. data:{
  8. activeColor: 'red',
  9. size: '30px',
  10. shadow: '5px 2px 6px #000'
  11. }
  12. })
  13. </script>

2.1

  1. <div id="app">
  2. <span class="box" :style="styleObject">我是字</span>
  3. </div>
  4. <script>
  5. new Vue({
  6. el: "#app",
  7. data:{
  8. styleObject:{
  9. color: 'red',
  10. fontSize: '30px',
  11. textShadow: '5px 2px 6px #000'
  12. }
  13. }
  14. })
  15. </script>

2.2

  1. <div id="app">
  2. <span class="box" :style="[styleA,styleB]">我是字</span>
  3. </div>
  4. <script>
  5. new Vue({
  6. el: "#app",
  7. data:{
  8. styleA:{
  9. fontSize: '30px',
  10. color: 'red'
  11. },
  12. styleB:{
  13. textShadow: '5px 2px 6px #000'
  14. }
  15. }
  16. })
  17. </script>
  18.  
  19. 2.3

2.3

  1. <div id="app">
  2. <span class="box" :style="[isA?styleA:'', styleB]">我是字</span>
  3. </div>
  4. <script>
  5. new Vue({
  6. el: "#app",
  7. data:{
  8. styleA:{
  9. fontSize: '30px',
  10. color: 'red'
  11. },
  12. styleB:{
  13. textShadow: '5px 2px 6px #000'
  14. },
  15. isA: false
  16. }
  17. })
  18. </script>
  19.  
  20. 2.4

2.4

3.v-bind:src

  1. <div id="app">
  2. <img :src="url" />
  3. </div>
  4. <script>
  5. new Vue({
  6. el: "#app",
  7. data:{
  8. url: "../img/pg.png"
  9. }
  10. })
  11. </script>

3.1

4.v-bind:title

  1. <div id="app">
  2. <div :title="message">我是字</div>
  3. </div>
  4. <script type="text/javascript">
  5. new Vue({
  6. el: "#app",
  7. data:{
  8. message:"我是吱吱"
  9. }
  10. })
  11. </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. php中array_walk() 和 array_map()两个函数区别

    两个函数的共性和区别: 1.传入这两个函数的 $value,就是数组中的单一个元素. 2.array_walk() 仅返回true或者false,array_map() 返回处理后的数组: 3.要得到 ...

  2. xml文件读取到数据库

    xml文件读取到数据库   第一步,导包 c3p0,dom4j,jaxen,MySQL-connector 第二步  xml文件,config文件 第三步 javabean 第四步 c3p0的工具类 ...

  3. filter() 方法创建一个新数组

    filter快速过滤创建一个新数组 var new_array = arr.filter(callback(element[, index[, array]])[, thisArg]) 参数节 cal ...

  4. Java jdbc入门

    1 jdbc入门 1.1 之前操作数据 1)通过mysql的客户端工具,登录数据库服务器  (mysql -u root -p 密码) 2)编写sql语句 3)发送sql语句到数据库服务器执行 1.2 ...

  5. Windows API 编程----将错误代码转换成错误描述信息

    Windows编程有时会因为调用函数而产生错误,调用GetLastError()函数可以得到错误代码.如果错误代码为0,说明没有错误:如果错误代码不为0,则说明存在错误. 而错误代码不方便编程人员或用 ...

  6. Magisk+Xposed+Root switch+Pokémon GO

    If you follow Android Police, there's a good chance you've got a rooted device, whether it be an eas ...

  7. C# Winform中的ComboBox控件绑定数据库项目作为列表内容

    //初始化院区下拉列表,使用了Oracle数据库中的表项目 try { //string connString = "User=system;Password=manager;Data So ...

  8. 消息循环中的TranslateMessage函数和DispatchMessage函数,特别注意WM_TIMER消息

    原文:http://www.cnblogs.com/xingrun/p/3583357.html TranslateMessage函数 函数功能描述:将虚拟键消息转换为字符消息.字符消息被送到调用线程 ...

  9. Jmeter参数化设置,多用户登录

    一.模拟多用户登录场景 如登录模式如下图所示,登录界面中需要输入:用户名.密码.验证码 用户名以及密码均是固定值,不需要做处理.验证码需要处理一下,可以后台配置成固定值,具体可以找开发咨询. 在此场景 ...

  10. SQL点点滴滴_删除临时表

    select into 创建的表属于临时表,判断是否存在的方法 select c_adno,c_con_no into #temp from tb_contract IF OBJECT_ID( 'te ...