• vueDemo


     实现代码

    <div id="app">
            手机:<input type="text" v-model="newProject.name" value="" name="phone">
            库存:<input type="text" value="0" v-model="newProject.num" name="number">
            <input type="submit" @click="add()" value="提交">
            <p v-if="goods.length==0">没有商品了!</p>
            <ul v-else>
                <li v-for="(item ,i) in goods" :k="i">
                    商品:{{item.name}},库存:{{item.num}}
                    <button type="button"  @click="del(i)">删除</button>
                </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,
                        })                   
                    },
                    del:function(i){
                        this.goods.splice(i,1);
                    }
                }
            })
            vm.$mount("#app");
        </script>
    时间如白驹过隙,忽然而已,且行且珍惜......
  • 相关阅读:
    PHP做Web开发的MVC框架(Smarty使用说明 )
    PHP + Smarty + html5 构建Wap应用
    HTML5游戏中动画帧的概念理解
    [转]jQuery选择器 (详解)
    2014马年应该有怎么样的学习方式和思考原则
    html5视频播放解决方案
    html5学习摘要
    sqlserver2008行锁
    关于一些url中传递参数有空格问题
    MongoDB和Redis区别
  • 原文地址:https://www.cnblogs.com/UnfetteredMan/p/13140671.html
Copyright © 2020-2023  润新知