vue中v-for指令實例

功能:
展示數組元素及其索引

實現:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>v-show</title>
    <!--引入vue-->
    <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>
<body>
<div id="myif">
    <ul>
        <li v-for="(item,index) of list">{{item}} , {{index}}</li>
    </ul>
</div>
<script>
    new Vue({
        el:"#myif",
        data:{
            list:["xiaoming","jack","tom"]
        }
    })
</script>
</body>
</html>

運行結果:
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章