• Vue(三)两个案例(todolist,tableBar)


    待办事项:

    <!DOCTYPE html>
    <html lang="en">
    
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta http-equiv="X-UA-Compatible" content="ie=edge">
            <title>Document</title>
            <style>
                #addItem{
            font-size: 28px;
            vertical-align: middle;  
        }
        #txt{
            height: 30px;
             250px;
            vertical-align: middle;
        }
        li{
            list-style: none;
             400px;
            height: 70px;
            line-height: 70px;
            border: 1px solid lightgreen;
        }
        li:hover{
            background: lightcoral;
        }
    </style>
            <script src="./vue.js"></script>
        </head>
    
        <body>
            <div id="box">
                <input id="txt" type="text"><button id="addItem" v-on:click='createList'>+</button>
                <ul>
                    <li v-for='(item,index) in list'>{{item.value}}
                        <span v-if='item.sure' style="color:red;font-size: 18px">Be Sure</span>
                        <button v-on:click="delItem(index)">Del</button>
                        <button v-if='!item.sure' v-on:click='item.sure=true'>Sure</button>
                    </li>
                </ul>
            </div>
            <script>
                let add = new Vue({
                    el: '#box',
                    data: {
                        list: []
                    },
                    methods: {
                        createList() {
                            this.list.push({
                                value: txt.value,
                                sure: false
                            });
                        },
                        delItem(num){
                            this.list.splice(num,1);
                        }
                    }
                });
            </script>
        </body>
    
    </html>

    table选项卡:

    <!DOCTYPE html>
    <html lang="en">
    
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta http-equiv="X-UA-Compatible" content="ie=edge">
            <title>Document</title>
            <style>
                li {
                    list-style: none;
                    text-align: center;
                }
    
                #box {
                     280px;
                    margin: 50px auto;
                    background: lightblue;
                }
    
                #box:after {
                    content: '';
                    height: 0;
                    clear: both;
                    visibility: hidden;
                    display: block;
                }
    
                #title li {
                     50px;
                    height: 30px;
                    float: left;
                    padding: 20px 15px;
                }
    
                #title li:hover {
                    background: lightcoral;
                }
    
                #content {
                    display: block;
                }
            </style>
            <script src="./vue.js"></script>
        </head>
    
        <body>
            <div id="box">
                <ul id="title">
                    <li v-for='(item,index) in list' v-on:click='changeContent(index)'>{{index}}</li>
                </ul>
                <ul id="content">
                    <li v-for='(item,index) in list[str]'>{{item}}</li>
                </ul>
            </div>
            <script>
                var vm = new Vue({
                    el: '#box',
                    data: {
                        list: {
                            'movie': ['aaa', 'bbb', 'ccc', 'ddd', 'aaa', 'bbb', 'ccc', 'ddd', 'aaa', 'bbb', 'ccc',
                                'ddd', 'aaa', 'bbb', 'ccc', 'ddd'
                            ],
                            'game': ['eee', 'fff', 'ggg', 'hhh', 'eee', 'fff', 'ggg', 'hhh', 'eee', 'fff', 'ggg',
                                'hhh', 'eee', 'fff', 'ggg', 'hhh', 'eee', 'fff', 'ggg', 'hhh'
                            ],
                            'music': ['iii', 'jjj', 'kkk', 'lll', 'mmm', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'iii',
                                'jjj', 'kkk', 'lll', 'mmm', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'iii', 'jjj',
                                'kkk', 'lll', 'mmm'
                            ]
                        },
                        str: ''
                    },
                    methods: {
                        changeContent(data) {
                            this.str = data;
                        }
                    }
                });
            </script>
        </body>
    
    </html>
  • 相关阅读:
    socket协议和http协议性能对比
    PHP对象在内存中的分配
    如何打造高性能Web应用
    ubuntu 16.04 实现远程图形界面连接
    NACOS升级操作
    ulimit 更改 gcc升级 查看显卡状态命令
    CentOS7下firewall-cmd防火墙使用
    Nacos 1.1.0发布,支持灰度配置和地址服务器模式
    NGINX限流配置
    学Redis
  • 原文地址:https://www.cnblogs.com/HelloWorld-Yu/p/10205456.html
Copyright © 2020-2023  润新知