<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
<div id="app">
<div v-if='v==12' v-for='(v,k,i) in obj'>{{v+'---'+k+'----'+i}}</div>
</div>
<script type="text/javascript" src="./js/vue.js"></script>
<script>
var obj = {
uname: 'geyao',
age: 12,
gender: 'male'
}
for (var key in obj) {
console.log(key, obj[key]);
}
var vm = new Vue({
//绑定的标签
el: '#app',
//自定义按键修饰符
data: {
obj: {
uname: 'geyao',
age: 12,
gender: 'male'
}
},
methods: {
//控制元素样式是否显示
handle: function() {
this.flag = !this.flag;
}
}
});
</script>
</body>
</html>
总结