zoukankan      html  css  js  c++  java
  • vue中的样式

    一、使用class样式:

             CSS部分:  

     1     <style>
     2         .green{
     3             color:green;
     4         }
     5 
     6         .italic{
     7             font-style:italic;
     8         }
     9 
    10         .thin{
    11             font-weight:200;
    12         }
    13 
    14         .active{
    15             /* 字符间距 */
    16             letter-spacing: 0.5em;
    17         }
    18 
    19     </style>

      JS部分:

    1     var app = new Vue({
    2             el: "#app",
    3             data() {
    4                 return {
    5                     flag:true,
    6                     styleObj:{green:true,thin:true}
    7                 }
    8             }
    9         });
    1. 数组  
    <h1 :class=['thin','italic']>这是一个H1标签的内容</h1>

      2.数组中的三元表达式

    <h1 :class=['thin','italic',flag?'active':'']>这是一个H1标签的内容</h1>

      3.数组中嵌套对象

    <h1 :class=['thin','italic',{'active':flag}]>这是一个H1标签的内容</h1>

      4.直接使用对象

    <h1 :class="{green:true,thin:true}">这是一个H1标签的内容</h1>

      5.直接引用对象

    <h1 :class="styleObj">这是一个H1标签的内容</h1>

    二、使用内联样式

      JS部分:

     1     var app = new Vue({
     2             el: "#app",
     3             data() {
     4                 return {
     5                     flag:true,
     6                     styleObj:{green:true,thin:true},
     7                     cssObj:{color:'red','font-weight':200},
     8                     cssObj1:{'font-style':'italic'},
     9                 }
    10             }
    11         });

      1、直接使用CSS对象

    1 <h1 :style="{color:'red','font-weight':200}">这是一个H1标签的内容</h1>

      2、使用js对象

    1 <h1 :style="cssObj">这是一个H1标签的内容</h1>

      3、使用多个样式

    <h1 :style=[cssObj,cssObj1]>这是一个H1标签的内容</h1>
  • 相关阅读:
    你知道RAID的初始化过程吗?
    Dynamic Disk Pool技术解析
    Ubuntu-16.04.6 安装 oracle 11.2.0.4 数据库database软件
    Ubuntu-16.04.6 安装 oracle 12.2.0.1 数据库database软件
    IDEA 快捷键
    Redis 常用操作命令
    甘特图
    PERT图
    现金贷
    线上信贷提供解决方案
  • 原文地址:https://www.cnblogs.com/chenzongyan/p/10260472.html
Copyright © 2011-2022 走看看