12345678910111213141516171819202122232425262728293031323334353637 |
- <!DOCTYPE html>
- <html lang="zh">
- <head>
- <title></title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script src="https://unpkg.com/vue/dist/vue.js"></script>
- <link href="../css/style.css" rel="stylesheet"> </head>
- <body>
- <div id="app">
- <p style="font-size:25px;">计数器: {{ counter }}</p>
- <button v-on:click="counter++" style="font-size:25px;">点我</button>
- <button @click="counter++" style="font-size:25px;">点我</button>
- </div>
- <script type="text/javascript">
- var vm = new Vue({
- el: '#app',
- data: {
- counter: 1
- },
- watch: {
- searchQuery: function(query) {
- this.isSearch = false;
- this.items.push(query);
- }
- }
- });
- vm.$watch('counter', function(nval, oval) {
- //alert('计数器值的变化 :' + oval + ' 变为 ' + nval + '!');
- });
- </script>
- </body>
- </html>
|