<div id="app">
    <button v-on:click="add(10)">click me</button>
    <button v-on:click="remove(5)">click me</button>
    <button v-on:click="num++">click me</button>
    <button v-on:click="num--">click me</button>
    <span>{{num}}</span>
</div>
<script src="js/vue.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            num:0,
            message: '6',
            data: {
                name: '',
                gender: '',
                interest: [],
                identity: ''
            },
            selected: 'A',
            options: [
                { text: 'One', value: 'A' },
                { text: 'Two', value: 'B' },
                { text: 'Three', value: 'C' }
            ]
        },
        methods:{
            add:function (inc){
                this.num += inc;
         },
            remove:function (dec){
                this.num -= dec;
            },
        }
    })
</script>
Logo

前往低代码交流专区

更多推荐