1. style样式绑定处理

1.1. 对象语法

<div v-bind:style="{width: '400px', height: '50px'}"></div>

1.2. 数组语法

<div v-bind:style="[{width: 400px'}, {height: '50px'}]"></div>

2. 对象绑定style

2.1. 代码

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>对象绑定style</title></head><body><div id="app"><div><span v-bind:style="{border: borderStyle, width: widthStyle, height: heightStyle, display: displayStyle}">对象绑定style</span><br /><button @click="handle1">切换样式</button></div><br /><div><span v-bind:style="objStyle">对象绑定style简化</span><br /><button @click="handle2">切换样式</button></div></div><script type="text/javascript" src="vue.min.js"></script><script type="text/javascript">var vm = new Vue({el: "#app",data: {borderStyle: "solid 1px",widthStyle: "400px",heightStyle: "50px",displayStyle: "block",objStyle: {border: "solid 1px", width: "400px", height: "50px", display: "block"}},methods: {handle1: function(event) {this.widthStyle = "200px";},handle2: function(event) {this.objStyle.width = "200px";}}});</script></body>
</html>

2.2. 效果图

2.3. 点击2个切换样式按钮后

3. 数组绑定style

3.1. 代码

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><title>数组绑定style</title></head><body><div id="app"><div><span v-bind:style="[{border: borderStyle, width: widthStyle, height: heightStyle, display: displayStyle}, {color: colorStyle}]">数组绑定style</span><br /><button @click="handle1">切换样式</button></div><br /><div><span v-bind:style="arrStyle">数组绑定style简化</span><br /><button @click="handle2">切换样式</button></div></div><script type="text/javascript" src="vue.min.js"></script><script type="text/javascript">var vm = new Vue({el: "#app",data: {borderStyle: "solid 1px",widthStyle: "400px",heightStyle: "50px",displayStyle: "block",colorStyle: "red",arrStyle: [{border: "solid 1px", width: "400px", height: "50px", display: "block"}, {color: "red"}]},methods: {handle1: function(event) {this.widthStyle = "200px";},handle2: function(event) {this.arrStyle[0].width = "200px";}}});</script></body>
</html>

3.2. 效果图

3.3. 点击2个切换样式按钮后

007_Vue style样式绑定相关推荐

  1. vue中绑定style样式的方式

    vue中绑定样式的方式有多种 下面就来看看吧 开始之前先准备一些样式 css样式 <style>.red {color: red}.green {color: green}.big {fo ...

  2. Vue.js框架学习—绑定style样式

    一.对象写法 模板和Vue实例 <body><div id="root"><div :style="styleObj">{{ ...

  3. 23.Vue绑定style样式

    目录 1.style样式对象写法 2.style样式数组写法 3.总结 22.Vue绑定class样式_爱米酱的博客-CSDN博客为了讲好class样式,我们这里提前准备了7个样式作为例子来讲解. b ...

  4. WPF 绑定继承的样式提示 只能根据带有基类型 IFrameworkInputElement 的目标类型的 Style 样式

    在 WPF 中,如果有一个样式是继承另一个样式,而样式没有使用 TargetType 那么在运行的时候会提示 只能根据带有基类型 IFrameworkInputElement 的目标类型的 Style ...

  5. Attribute 绑定、类绑定和样式绑定

    Attribute 绑定.类绑定和样式绑定 1. 绑定到 Attribute 优先设置带有 Property 绑定的元素的 Property.如果没有可绑定的元素 Property,可以使用 Attr ...

  6. 【Ant Design Pro 三】样式动态绑定 react样式绑定

    第一步,创建样式文件,在页面目录下根据自己习惯创建一个less文件,用来写样式类 第二部,引用该文件 import styles from './details.less'; //details.le ...

  7. 案例:简单计算器|| 属性绑定||v-model指令的本质||样式绑定

    需求:实现简单的加法计算,分别输入数值a和数值b ,点击计算按钮,结果显示在下面. <!DOCTYPE html> <html lang="en"> < ...

  8. Vue.js学习系列(三十四)-- Vue.js样式绑定(五)

    2019独角兽企业重金招聘Python工程师标准>>> 2. Vue.js style(内联样式) 我们可以在 v-bind:style 直接设置样式: <!DOCTYPE h ...

  9. 五十九、Vue中的样式绑定

    @Author:Runsen @Date:2020/10/16 大四是一个焦虑的时期.烦恼有时候是具体问题带来的压力,有时候却是无端的.莫名其妙的,有时候还极易受到外界的影响,别人一句话就会激起内心难 ...

最新文章

  1. adb: unable to connect for root: more than one device/emulator
  2. 如何在Linux下安装MySQL8.0
  3. 基于R语言的梯度推进算法介绍
  4. sudo su su_Spring Security应用程序中的su和sudo
  5. 连续加班2周做出来的功能,老板说先不做了
  6. 大象喝水(信息学奥赛一本通-T1032)
  7. 数据结构之内部排序二
  8. asio定时器深度探析
  9. 为什么你必须了解云原生?!
  10. Java三月春招面试经历分享(没offer不是我的锅)
  11. XINS 3.1.0 Alpha2 发布,远程 API 调用规范
  12. 【Gym — 101473 G】Lines of Containers【思维题】
  13. 12.2.4 TCP网络调试助手实例
  14. 常用设备管理口默认用户名密码汇总
  15. android手机微信收藏功能实现,微信小程序收藏功能的实现代码
  16. 思科路由器配置NAT地址转换
  17. 3GPP TS 23501-g51 中英文对照 | 4.2.8 Support of non-3GPP access
  18. C语言中void*详解及应用
  19. VBA,把excel单元格复制成图片
  20. 邓应海:美联储缩表预期升温黄金下挫!最新黄金走势分析

热门文章

  1. zabbix报错:Zabbix服务启动不了
  2. Go 定时器和断续器
  3. (LeetCode 92)Reverse Linked List II
  4. Android学习笔记-Service
  5. Delphi字符串函数Delete
  6. IoAttachDevice源码
  7. hdu 1043 ,pku 1077 Eight ,八数码问题
  8. 在CentOS7.2上部署Postgres-XL分布式数据库
  9. PostgreSQL字符集问题
  10. shell-4.bash的变量:用户自定义变量