vue的组件 Vue.component

vue的组件 Vue.component
在标签上用v-bin:组件名 =“循环单属性”

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">

<zsp v-for="item in items" v-bind:sp="item"></zsp>

</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.min.js"></script>
<script>
    Vue.component("zsp",{
        props:['sp'],
        template:'<li>{{sp}}</li>'
    });
    var vue =new Vue({
        el: '#app',
        data:{
            items:['java','c','c++']
        }
    });
</script>
</body>
</html>
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页