1234567891011121314151617181920212223242526272829303132333435363738 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <div id="app">
- <input type="button" value="v-on指令" v-on:click="fn1">
- <input type="button" value="v-on简写" @click="fn1">
- <input type="button" value="v-on双击" v-on:dblclick="fn1">
- <h2>{{food}}</h2>
- <input type="button" value="单击修改食物" @click="changeFood">
- </div>
- <script src="./vue.js"></script>
- <script>
- var app = new Vue({
- el: "#app",
- data: {
- food: '西红柿'
- },
- methods: {
- fn1(){
- alert('我是点击事件')
- },
- changeFood(){
- this.food = '土豆'
- }
- }
- })
- </script>
- </body>
- </html>
|