<template>
<div>
<p v-bind:class="{active:isActive,'demo':Demo}">嘿嘿</p>
<p v-bind:class="styleObj">哈哈</p>
<p v-bind:class="styleObj2">咯吱咯吱</p>
<p v-bind:class="[active1]">呵呵</p>
<p v-bind:class="[{active:isActive},'info-'+id]">呵呵2</p>
<div>
<ul>
<li :class="[{active:index%2==0},'info-'+id]" v-for="(name,index) in names">{{name}}</li>
</ul>
</div>
<div>
<p :style="stob">你来了</p>
</div>
</div>
</template>

<script>
export default {
name: 'styles',
data() {
return {
isActive: true,
Demo: true,
styleObj:{
active:true,
'demo':false
},
active1:'active',
id:10,
names:['小明','小红','小军'],
stob :{
color:'red',
fontSize:'30px'
}
}
},
methods: {

},
computed:{
styleObj2(){
return{
'active':this.isActive,
'demo':this.Demo
}
}
}
}
</script>

<style>
.active {
color: darkgreen;
}
</style>

vue中,class与style绑定的更多相关文章

  1. Vue中class与style绑定

    gitHub地址:https://github.com/lily1010/vue_learn/tree/master/lesson07 一 用对象的方法绑定class 很简单,举个栗子: <!D ...

  2. 关于vue.js中class与style绑定的学习

    练习代码: html: <!DOCTYPE html><html lang="en"><head> <meta charset=" ...

  3. vue中的数据双向绑定

    学习的过程是漫长的,只有坚持不懈才能到达到自己的目标. 1.vue中数据的双向绑定采用的时候,数据劫持的模式.其实主要是用了Es5中的Object.defineProperty;来劫持每个属性的get ...

  4. vue 的 Class 与 Style 绑定

    操作元素的 class 列表和内联样式是数据绑定的一个常见需求.因为它们都是属性,所以我们可以用 v-bind 处理它们:只需要通过表达式计算出字符串结果即可.不过,字符串拼接麻烦且易错.因此,在将 ...

  5. vue基础——Class与Style绑定

    Class与Style绑定 操作元素的class列表和内联样式是数据绑定的一个常见的需求. 因为它们都是属性,所以我们可以用v-bind来处理它们:只需要通过表达式计算出字符串结果即可.不过,字符串拼 ...

  6. vue中v-model 数据双向绑定

    表单输入绑定 v-model 数据双向绑定,只能应用在input /textare /select <div id="app"> <input type=&quo ...

  7. 前端框架之Vue(4)-Class与Style绑定

    操作元素的 class 列表和内联样式是数据绑定的一个常见需求.因为它们都是属性,所以我们可以用 v-bind 处理它们:只需要通过表达式计算出字符串结果即可.不过,字符串拼接麻烦且易错.因此,在将  ...

  8. vue基础---Class 与 Style 绑定

    [一]绑定HTML Class (1)对象语法 ①普通绑定class <div id="area" v-bind:class="className"> ...

  9. vue中html模板使用绑定的全局函数

    我们知道在script中使用vue绑定的全局函数时, 我们需要用这种方式使用: this.Util.Fun(e) 那在模板中, 比如v-if中想使用Fun函数怎么办呢?你应该这样做 <i v-i ...

随机推荐

  1. VS2015 将*.xaml.cs文件包裹在*.xaml文件下

    原文:https://stackoverflow.com/questions/13387527/add-existing-xaml-files-to-visual-studio-2012 Right- ...

  2. 各厂商服务器存储默认管理口登录信息(默认IP、用户名、密码)收集

    666:https://blog.csdn.net/xiezuoyong/article/details/84997917

  3. [转] createObjectURL方法 实现本地图片预览

    ie6 可以直接显示本本地路径的图片 如: <img src="file://c:/3.jpg" />  ~~~网上都说ie7就不支持这种文件系统路径的url,但测试 ...

  4. springboot学习(一):创建项目

    package com.glory.demo.Controller; import org.springframework.stereotype.Controller; import org.spri ...

  5. CTAP: Complementary Temporal Action Proposal Generation (ECCV2018)

    互补时域动作提名生成 这里的互补是指actionness score grouping 和 sliding window ranking这两种方法提proposal的结合,这两种方法各有利弊,形成互补 ...

  6. centos7 yum install redis

    直接yum 安装的redis 不是最新版本 yum install redis 如果要安装最新的redis,需要安装Remi的软件源,官网地址:http://rpms.famillecollet.co ...

  7. mysql inner jion多表查询

    select vtiger_users.id, vtiger_users.user_name, vtiger_role.rolename FROM vtiger_users inner join vt ...

  8. 在ionic2中集成swiper插件

    1. 下载官方的js和css文件分别放在assets下的js和css文件夹,然后在index.html中引入 <!DOCTYPE html> <html lang="en& ...

  9. js自定义滚动样式

    <!DOCTYPE html> <html lang="en"> <head> <style type='text/css'> ht ...

  10. datatable 转list ,list转datatable

    方法一:  public static IList<T> ConvertToModel(DataTable dt)             {                // 定义集合 ...