• vue动态绑定类(实现tab)


    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <script src="https://cdn.jsdelivr.net/npm/vue"></script>
        <style>
            .box {
                color: rebeccapurple;
            }
    
            .box_width {
                width: 400px;
                height: 400px;
                background-color: red;
                border: 1px solid green;
            }
    
            .uli {
                display: flex;
                list-style: none;
            }
    
            .uli li {
                margin: 15px;
            }
    
            .uli li:hover {
                cursor: pointer;
            }
    
            .back {
                color: red;
                background-color: royalblue;
            }
    
            .backfalse {
                background-color: green;
                color: white;
            }
        </style>
    </head>
    
    <body>
        <div id="app">
            <div :class="bindClass">{{msg}}</div>
            <button @click="btn('add')">增加样式</button>
            <button @click="btn('cutback')">减少样式</button>
            <ul class="uli">
                <li v-for="(item,index) in arrs" :key="index" @click="ulBtn(index)"
                    :class="[index==isBack?'back':'backfalse']">
                    {{item}}
                </li>
            </ul>
        </div>
        <script>
            new Vue({
                el: "#app",
                data: {
                    msg: "测试",
                    bindClass: "",
                    arrs: ["便签一", "便签二", "便签三"],
                    isBack: 0,
                },
                methods: {
                    btn(data) {
                        if (data == "add") {
                            this.bindClass = "box box_width";
                        } else {
                            this.bindClass = "";
                        }
                    },
                    ulBtn(e) {
                        this.isBack = e
                    },
                },
            });
        </script>
    </body>
    
    </html>
  • 相关阅读:
    单向链表
    野指针和空指针
    指针数组和数组指针,指针函数和函数指针
    python开发笔记-变长字典Series的使用
    python开发笔记-DataFrame的使用
    python开发笔记-如何做数据准备
    python开发笔记-通过xml快捷获取数据
    destoon系统结构大全
    Python应用之-修改通讯录
    Python开发应用-操作excel
  • 原文地址:https://www.cnblogs.com/lyt520/p/14674555.html
Copyright © 2020-2023  润新知