<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<ul id="repeat-object" class="demo">
<li v-for="value in object">
{{$key}}:{{value}}
</li>
</ul>
</body>
</html>
<script src="http://cdn.bootcss.com/vue/1.0.12/vue.js">
new Vue({
el:"#repeat-object",
data:{
object:{
FirstName:"John",
LastName:"Doe",
Age: 30
}
}
})
</script>
前端小白,这段代码是从vue的官方教程上抄过来练习的,但是v-for处有错,显示“Attribute v-for is not allowed here”
看下你的cdn有没有引入成功吧:
改成:
我觉得循序渐进,打好基础才是王道
html->javascript->vuejs->...
不然踩坑浪费的时间太多了