|
@@ -0,0 +1,43 @@
|
|
|
+<!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>
|
|
|
+ </div>
|
|
|
+ <script src="vue.js"></script>
|
|
|
+ <script>
|
|
|
+ new Vue({
|
|
|
+ el:"#app",
|
|
|
+ data:{
|
|
|
+ arr:['a','b','c','d'],
|
|
|
+ person:{
|
|
|
+ name:'zs'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods:{
|
|
|
+ change(){
|
|
|
+ console.log(1111)
|
|
|
+ // this.arr[0] = 'x'
|
|
|
+ /* Vue中 不能使用数组[索引]的方式 去修改数组 因为页面不更新 */
|
|
|
+ /* Vue 要大写 */
|
|
|
+ /* Vue.set(data数据,修改值的索引,修改的参数) */
|
|
|
+ // Vue.set(this.arr,0,'x')
|
|
|
+ Vue.set(this.person,'name','lisi')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|