123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <!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">
- <button @click="change()">修改</button>
- <ul>
- <li v-for="(val,index) in arr">
- {{val}}
- {{index}}
- </li>
- </ul>
- {{person.name}}
- </div>
- <script src="./vue.js"></script>
- <script>
- var app = new Vue({
- el: '#app',
- data:{
- arr: ['a','b','c','d','e'],
- person: {
- name: 'zs'
- }
- },
- methods:{
- change(){
- console.log(1111)
- // this.arr[0] = 'x'
- //在Vue中 不能使用数组[索引] 这样的方式修改数组
- //Vue.set(data数据,修改值的索引,修改的值)
- Vue.set(this.person,'name','lisi')
- }
- }
- })
- </script>
- </body>
- </html>
|