SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html lang="en">

<head>
    <title>methods options</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>

<body>
    <h1>methods options</h1>
    <hr>
    <div id="app">
        {{a}}
        <p><button @click="add(2)">add</button></p>
    </div>

    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                a: 1
            },
            methods: {
                add:function(num){
                    if (num!=null) {
                        this.a+=num
                    } else {
                        this.a++;
                    }
                }
            },
        })
    </script>
</body>

</html>

本项目引用的自定义外部资源