zoukankan      html  css  js  c++  java
  • 渡一Vue:Vue代码:1-5

    1.获取表单添加到页面数据

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
    </head>
    
    <body>
        <div id="app">
            <h2>{{title}}</h2>
            <span>名称:</span><input type="text" v-model="newProduct.name">
            <span>库存:</span><input type="text" v-model="newProduct.stock" type="number">
            <button @click="addProduct">添加</button>
            <ul>
                <li v-for="(item,index) in product" :key="index">{{item.name}} 库存: {{item.stock}}</li>
            </ul>
        </div>
        <script>
            var vm = new Vue({
                el: "#app",
                data: {
                    title: "商品管理",
                    product: [
                        { name: "华为", stock: 10 },
                        { name: "小米", stock: 5 },
                        { name: "苹果", stock: 11 }
                    ],
                    newProduct: {
                        name: "",
                        stock: 0
                    }
                },
                methods: {
                    addProduct: function () {
                        this.product.push({
                            name: this.newProduct.name,
                            stock: this.newProduct.stock
                        })
                    }
                }
    
    
            })
        </script>
    </body>
    
    </html>
    
  • 相关阅读:
    iOS9 HTTP 不能正常使用的解决办法
    IOS UIWebView的一些用法总结
    顺序查找
    循环队列
    队列的链式存储实现
    栈的链式存储实现
    顺序表的实现
    MessageBox函数
    二分法查找
    冒泡排序
  • 原文地址:https://www.cnblogs.com/li33/p/13509329.html
Copyright © 2011-2022 走看看