Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
06-for.html 1.03 KB
Copy Edit Raw Blame History
ouqianbei authored 2021-03-16 17:24 . add
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="node_modules/vue/dist/vue.js"></script>
</head>
<body>
<div id="box">
<ul>
<li v-for="(user,index) in users">
{{index}}--{{user.name}}--{{user.age}}
</li>
</ul>
<ul>
<li v-for="(value,key,index) in person">
{{value}}--{{key}}--{{index}}
</li>
</ul>
</div>
<script>
/**
* v-for:遍历data中的数组和对象;其中还可以带参数
* @type {Vue}
*/
var vue = new Vue({
el: "#box",
data: {
users: [
{ name: "小红", age: "18" },
{ name: "小黄", age: "15" },
{ name: "小蓝", age: "17" }
],
person: {
name: "大红", age: "20", job: "java"
}
}
})
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化