• vue4 属性 class style


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        url:'https://www.baidu.com/img/bd_logo1.png',
                        w:'200px',
                        t:'这是一张美丽的图片'
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <!--<img src="{{url}}" alt=""> 这种方式会报404错 -->   属性是通过bind来绑定的
            <img v-bind:src="url" alt="">
            <img :src="url" alt="">
            <img :src="url" alt="" :width="w" :title="t">
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
            .red{
                color: red;
            }
            .blue{
                background: blue;
            }
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        red:'red', //是style的red
                        b:'blue'
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">   //red是data里面的red,多个
            <strong :class="[red,b]">文字...</strong>
            <strong :class="red">文字...</strong> //单个data里面的red
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
            .red{
                color: red;
            }
            .blue{
                background: blue;
            }
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">   //不是data里的red,是style的red,true表示生肖,
            <strong :class="{red:true,blue:true}">文字...</strong>
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
            .red{
                color: red;
            }
            .blue{
                background: blue;
            }
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        a:true,
                        b:false
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">//不是data里的red,是style的red,true表示生肖,
            <strong :class="{red:a,blue:b}">文字...</strong>
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
            .red{
                color: red;
            }
            .blue{
                background: blue;
            }
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        json:{
                            red:true,
                            blue:true
                        }
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <strong :class="json">文字...</strong>
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
            .red{
                color: red;
            }
            .blue{
                background: blue;
            }
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
    
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <strong :style="{color:'red'}">文字...</strong>
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
            .red{
                color: red;
            }
            .blue{
                background: blue;
            }
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        c:{color:'red'}
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <strong :style="[c]">文字...</strong>
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
            .red{
                color: red;
            }
            .blue{
                background: blue;
            }
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        c:{color:'red'},
                        b:{backgroundColor:'blue'}
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <strong :style="[c,b]">文字...</strong>
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
            .red{
                color: red;
            }
            .blue{
                background: blue;
            }
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        a:{
                            color:'red',
                            backgroundColor:'gray'  //js里面的驼峰写法
                        }
                    },
                    methods:{
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <strong :style="a">文字...</strong>
        </div>
    </body>
    </html>
  • 相关阅读:
    Java自学第8期——多线程
    Java自学第7期——异常(Exception)
    Java自学第6期——Collection、Map、迭代器、泛型、可变参数、集合工具类、集合数据结构、Debug
    java自学第5期——Object、Date、Calender、System、StringBuilder、基本类型包装类
    下载com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
    博客园主题SimpleMemory详细配置项
    banner自用图床
    java自学第4期——:Scanner类、匿名对象介绍、Random类、ArrayList集合、标准类格式、String类、static静态、Arrays工具类、Math类(1)
    java自学第3期——继承、多态、接口、抽象类、final关键字、权限修饰符、内部类
    数组,哈希表,字典
  • 原文地址:https://www.cnblogs.com/yaowen/p/6974235.html
Copyright © 2020-2023  润新知