zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    运维人员常用的linux命令汇总
    Linux 入侵痕迹清理技巧
    xshell突出显示
    Linux终端显示中文
    mysql8.0设uuid函数为默认值
    Linux使用NFS作为文件共享目录服务
    修改docker运行容器的映射端口
    Apache-kafka以及zookeepeer单机安装
    kafka-confluent管控中心安装
    记CentOS8下安装Docker
  • 原文地址:https://www.cnblogs.com/HelloWorld-Yu/p/10205456.html
Copyright © 2011-2022 走看看