zoukankan      html  css  js  c++  java
  • vue实现简易留言板

    首先引入vue.js

    <script src="vue.js"></script>

    布局

    <div id="div">
        <input type="text" v-model="username" @keyup.enter="add()">
        <input type="button" value="按钮" @click="add()">
        <div v-show="this.arr.length ==0">暂无留言</div>
        <ul>
            <li v-for="item in arr">{{item}}
                <a href="javascript:;" @click="remove($index)">删除</a>
            </li>
        </ul>
    </div>

    js

     <script>
            window.onload = function () {
                new Vue({
                    el: '#div',
                    data: {
                        username: '',
                        arr: []
                    },
                    methods: {
                        add: function () {
                            this.arr.unshift(this.username);
                            this.username = '';
                        },
                        remove:function (index) {
                            this.arr.splice(index,1);
                        }
                    }
                });
            }
        </script>
  • 相关阅读:
    自然拼读
    windws蓝屏解决方案
    chrome
    ubuntu安装英伟达驱动
    ubuntu基础
    kvm(未完成2021-04-26)
    istio
    OpenSSH
    su 与 su -关系
    read命令/ declare/set
  • 原文地址:https://www.cnblogs.com/4thmonth/p/7152733.html
Copyright © 2011-2022 走看看