javascript - 抄了一段vue的实例,为什么v-for属性不能用呢?
大家讲道理
大家讲道理 2017-04-10 16:41:18
0
3
791
<!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”

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
黄舟
<script type="text/javascript" src="http://cdn.bootcss.com/vue/1.0.12/vue.js"></script>
<script type="text/javascript">
    new Vue({
        el:"#repeat-object",
        data:{
            object:{
                FirstName:"John",
                LastName:"Doe",
                Age: 30
            }
        }
    })
</script>
迷茫

看下你的cdn有没有引入成功吧:

<script src="http://cdn.bootcss.com/vue/1.0.12/vue.js">

改成:

<script src="https://cdn.bootcss.com/vue/1.0.12/vue.js">
Peter_Zhu

我觉得循序渐进,打好基础才是王道
html->javascript->vuejs->...
不然踩坑浪费的时间太多了

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!