美文网首页
vue.js 添加

vue.js 添加

作者: 王诺岚 | 来源:发表于2018-09-12 10:34 被阅读0次
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        li{
            list-style: none;
        }
    </style>
</head>
<body>
<div id="app">
    <input type="text" v-model="wang">
    <button v-on:click="alk">添加</button>
    <li v-for="w in msg">{{w}}</li>
</div>
<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            msg:["吃饭","睡觉","打豆豆"],
            wang:''
        },
        methods:{
            alk:function(){
                this.msg.push(this.wang),
                        this.wang=""
            }
        }
    })
</script>
</body>
</html>

相关文章

网友评论

      本文标题:vue.js 添加

      本文链接:https://www.haomeiwen.com/subject/rsnmgftx.html