首页 > 其他 > 详细

vue组件递归

时间:2017-02-16 22:53:20      阅读:304      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div id="example1">
    <div id="kk">你好</div>
    <example :num="0"></example>
</div>

<script src="https://unpkg.com/vue/dist/vue.js"></script>

<script type="text/javascript">
    Vue.component(example, {
        name: example,
        template: <span><span style="color:#F00;">{{num}}</span><example :num="num+1" v-if="currNum"></example></span>,
        props: [num],
        computed: {
            currNum: function () {
                return this.num < 10
            }
        }
    })

    var r = new Vue({
        el: #example1
    })
</script>
</body>
</html>

页面效果:

你好

012345678910

vue组件递归

原文:http://www.cnblogs.com/zhishaofei/p/6406998.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!