| 1234567891011121314151617181920212223242526272829303132333435 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <div id="app">
- <div>{{str}}</div>
- <!-- v-on: 事件绑定指令 可以将事件绑定到标签上 -->
- <!-- v-on: 可以缩写为 @ -->
- <!-- <button v-on:click="changeStr">按钮</button> -->
- <button @click="changeStr">按钮</button>
- </div>
- <script src="./js/vue.js"></script>
- <script>
- new Vue({
- el:"#app",
- data:{
- str:"hello world"
- },
- // vue2当中用来定义函数及事件处理函数的地方
- methods:{
- changeStr(){
- // console.log("按钮被点击了");
- console.log(this.str);
- this.str = "你好世界";
- }
- }
- })
- </script>
- </body>
- </html>
|