v-bind:的基本用法
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:的基本用法的更多相关文章
- MyBatis从入门到精通(第4章):MyBatis动态SQL【foreach、bind、OGNL用法】
(第4章):MyBatis动态SQL[foreach.bind.OGNL用法] 4.4 foreach 用法 SQL 语句中有时会使用 IN 关键字,例如 id in (1,2,3).可以使用 ${i ...
- js中.bind()和.call()用法讲解
var option = { ti : 8, it(){ return this.ti; } } 这里又一个option对象,it()方法里的this指的就是option对象的上下文. console ...
- 一个简单的例子让你很轻松地明白JavaScript中apply、call、bind三者的用法及区别
JavaScript中apply.call.bind三者的用法及区别 引言 正文 一.apply.call.bind的共同用法 二. apply 三. call 四. bind 五.其他应用场景 六. ...
- C语言中 v...printf类函数的用法
C语言的自学渐渐接近尾声,今天学到了标准库中的stdarg.h头,里面关联了stdio.h头里面的一类函数:v...printf函数,里面举的例子看了之后还是不太明白,google了一下依旧不是很懂, ...
- apply、call、bind区别、用法
apply和call都是为了改变某个函数运行时的上下文而存在的(就是为了改变函数内部this的指向): 如果使用apply或call方法,那么this指向他们的第一个参数,apply的第二个参数是 ...
- MyBatis bind标签的用法
From<MyBatis从入门到精通> <!-- 4.5 bind用法 bind标签可以使用OGNL表达式创建一个变量并将其绑定到上下文中. 需求: concat函数连接字符串,在M ...
- js中call,apply,bind方法的用法
call .apply.和bind 以上这三个方法都是js function函数当中自带的方法,用来改变当前函数this的指向. call()方法 语法格式: fun.call(thisArg[,ar ...
- C++11 bind和function用法
function是一个template,定义于头文件functional中.通过function<int(int, int)> 声明一个function类型,它是“接受两个int参数.返回 ...
- call(),apply(),bind() 区别和用法
call call 方法第一个参数是要绑定给this的值,后面传入的是一个参数列表.当第一个参数为null.undefined的时候,默认指向window. var arr = [1, 2, 3, 8 ...
- C++11 中的function和bind、lambda用法
std::function 1. std::bind绑定一个成员函数 #include <iostream> #include <functional> struct Foo ...
随机推荐
- php中array_walk() 和 array_map()两个函数区别
两个函数的共性和区别: 1.传入这两个函数的 $value,就是数组中的单一个元素. 2.array_walk() 仅返回true或者false,array_map() 返回处理后的数组: 3.要得到 ...
- xml文件读取到数据库
xml文件读取到数据库 第一步,导包 c3p0,dom4j,jaxen,MySQL-connector 第二步 xml文件,config文件 第三步 javabean 第四步 c3p0的工具类 ...
- filter() 方法创建一个新数组
filter快速过滤创建一个新数组 var new_array = arr.filter(callback(element[, index[, array]])[, thisArg]) 参数节 cal ...
- Java jdbc入门
1 jdbc入门 1.1 之前操作数据 1)通过mysql的客户端工具,登录数据库服务器 (mysql -u root -p 密码) 2)编写sql语句 3)发送sql语句到数据库服务器执行 1.2 ...
- Windows API 编程----将错误代码转换成错误描述信息
Windows编程有时会因为调用函数而产生错误,调用GetLastError()函数可以得到错误代码.如果错误代码为0,说明没有错误:如果错误代码不为0,则说明存在错误. 而错误代码不方便编程人员或用 ...
- 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 ...
- C# Winform中的ComboBox控件绑定数据库项目作为列表内容
//初始化院区下拉列表,使用了Oracle数据库中的表项目 try { //string connString = "User=system;Password=manager;Data So ...
- 消息循环中的TranslateMessage函数和DispatchMessage函数,特别注意WM_TIMER消息
原文:http://www.cnblogs.com/xingrun/p/3583357.html TranslateMessage函数 函数功能描述:将虚拟键消息转换为字符消息.字符消息被送到调用线程 ...
- Jmeter参数化设置,多用户登录
一.模拟多用户登录场景 如登录模式如下图所示,登录界面中需要输入:用户名.密码.验证码 用户名以及密码均是固定值,不需要做处理.验证码需要处理一下,可以后台配置成固定值,具体可以找开发咨询. 在此场景 ...
- SQL点点滴滴_删除临时表
select into 创建的表属于临时表,判断是否存在的方法 select c_adno,c_con_no into #temp from tb_contract IF OBJECT_ID( 'te ...