12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <script src="../vue.js"></script>
- </head>
- <body>
- <div id="app" >
- <!-- 参数 m没有参数 默认e 写参数 () 当前对象 其他 字符串 -->
- <button v-on:click="method1($event,'hello')" >按钮1</button>
- <!-- 简写 @click-->
- <button @click="method1($event,'hello')" >按钮2</button>
- <!-- 下拉框 -->
- name:<input type="text" @change="method2" v-model = "message" >
- <!-- a 标签 默认行为 -->
- <a href="https://baidu.com" @click="baidu">百度一下</a>
- <a href="https://baidu.com" @click.prevent="baidu">百度一下</a>
- </div>
- </body>
- <script>
- var jsonParam = {
- el: "#app",
- data: {
- message: "hello"
- },
- methods:{
- // 通过方法名()
- method1(e,t){
- console.log(e)
- console.log(t)
- console.log("点击事件别调用")
- },
- //change
- method2(){
- console.log(this.message)
- },
- //baidu
- baidu(){
- console.log("阻止默认事件")
- }
- }
- }
- var vue = new Vue(jsonParam);
- </script>
- </html>
|