123456789101112131415161718192021222324252627282930313233343536373839 |
- <!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">
- <div>
- <button v-on:click="counter += 1">增加 1</button>
- <p>这个按钮被点击了 {{ counter }} 次。</p>
- </div>
- <div>
- <button v-on:click="btnClick('测试1')">测试1</button>
- <button @click="btnClick('测试2')">测试2</button>
- </div>
- </div>
- <script>
- new Vue({
- el: '#app',
- data: {
- counter: 0
- },
- methods: {
- btnClick: function(pname) {
- this.mygame = pname;
- alert(pname);
- },
- },
- })
- </script>
- </body>
- </html>
|