• 第7节class与style绑定


    方法一 效果图:

     方法二 效果图:

     方法三 效果图:

     代码:

    <!DOCTYPE html>
    <html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link type="text/css" rel="stylesheet" href=" "/>
        <style type="text/css">
            * {
                margin: 0;
                padding: 0;
            }
        </style>
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    </head>
    <body>
    <p>1.方法一</p>
    <div id="one">
        <p v-bind:id="attribute_name">猜猜我是谁</p>
    </div>
    <script type="text/javascript">
        var el_vbind = new Vue({
            el: '#one',
            data:{
                attribute_name: 'id_red'
            }
        })
    </script>
    <style type="text/css">
        #id_red{
            color: red;
        }
    </style>
    <br/>
    <p>2.方法二</p>
    <div id="two">
        <p v-bind:class="{active: isActive,clsssNameTwo: isTwo}">哈哈哈哈哈</p>
        <!-- 渲染为以下:  就是等同于以下 当isActive: true,isTwo: true 时 -->
        <!-- <p class="active classNameTwo">哈哈哈哈哈</p>  -->
    </div>
    <script type="text/javascript">
        var el_vbind2 = new Vue({
            el:'#two',
            data:{
                isActive: true,
                isTwo: true
            }
        })
    </script>
    <style type="text/css">
        .active{
            color: blue;
        }
    </style>
    <br/>
    <p>3.方法三</p>
    <div id="three">
        <p v-bind:style="three_style">哎哟哦哦哦</p>
    </div>
    <script type="text/javascript">
        var el_vbind3 = new Vue({
            el:'#three',
            data:{
                three_style:{
                    color: 'green',
                    fontSize: '20px'
                }
            }
        })
    </script>
    </body>
    </html>
  • 相关阅读:
    Python老男孩 day09
    mount 挂载usb
    解压以及压缩命令
    flask 安装
    寻找文件 的小栗子
    Linux 环境变量与文件查找
    vim 查找和替换
    vim 基本功能 删除 移动 复制 粘贴
    selenium python 处理alter
    selenium python 显式和隐式等待方法
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/11570087.html
Copyright © 2020-2023  润新知