zoukankan      html  css  js  c++  java
  • vue中输入框v-mode绑定

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
        <div id="app">
            手机:<input type="text" v-model="newProject.name">
            库存:<input type="text" value="0" v-model="newProject.num">
            <input type="submit" @click="add()" value="提交">
            <ul>
                <li v-for="(item ,i) in goods" :k="i">
                    商品:{{item.name}},库存:{{item.num}}
                </li>
            </ul>
        </div>

        <script src="./js/vue.js"></script>
        <script>
            var vm = new Vue({
                el:"#app",
                data:{
                    newProject:{
                         name:'',
                         num:0
                    },
                    goods:[
                        {name:'iphone',num:10},
                        {name:'xiaomi',num:11}, 
                        {name:'huawei',num:12},
                    ]
                },
                methods:{
                    add:function(){
                        this.goods.push({
                            name:this.newProject.name,
                            num:this.newProject.num,
                        })
                    }
                }
            })
        </script>
    </body>
    </html>
    时间如白驹过隙,忽然而已,且行且珍惜......
  • 相关阅读:
    Python爬虫学习01
    Python学习Day02
    JavaScript学习笔记01
    Python学习Day01
    MarkDown实例代码
    MarkDwon的使用方法
    (转)探究requestDisallowInterceptTouchEvent失效的原因
    JNI字符串转字节数组指针方法
    justfun
    dsad
  • 原文地址:https://www.cnblogs.com/UnfetteredMan/p/13139570.html
Copyright © 2011-2022 走看看