<!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>
<span>
<input type="text" v-model='fname'>
</span>
</div>
<ul>
<li :key='index' v-for='(item,index) in list'>{{item}}</li>
</ul>
<div>
<div>{{info.name}}</div>
<div>{{info.age}}</div>
<div>{{info.gender}}</div>
</div>
</div>
<script type="text/javascript" src="./js/vue.js"></script>
<script>
var vm = new Vue({
el: '#app',
data: {
fname: '',
list: ['apple', 'orange', 'banana'],
info: {
name: 'list',
age: 12
}
},
methods: {
}
})
//
/* Vue.set(vm.list,2,'lemon'); */
vm.$set(vm.list, 2, 'lemon');
vm.info.gender = 'male';
</script>
</body>
</html>
运行结果
标签:info,vue,lemon,44,list,vm,Vue,set,前端 From: https://blog.51cto.com/u_15460007/6048823