Vue学习之v-for
1、html代码<!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
·
1、html代码
<!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">
<ul>
<li v-for="item in hobby">{{item}}</li>
</ul>
</div>
<script src="vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data() {
return {
message: '你好',
hobby: ['running', 'swimming', 'cooking'],
}
},
})
</script>
</body>
</html>
2、备注
(1)使用v-for指令遍历data.hobby,如果在console添加
app.hobby.push("reading")
页面会显示
更多推荐
已为社区贡献1条内容
所有评论(0)