首页 > 其他 > 详细

Vue——组件参数校验与非Props特性

时间:2019-10-28 01:05:12      阅读:107      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title>组件参数校验与非Props特性</title>
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    </head>

    <body>
        <div id="root">
            <child :content="‘组件参数校验‘"></child>
            <lastchild :text="‘非Props特性‘"></lastchild>
        </div>
        <script type="text/javascript">
            Vue.component(‘child‘, {
                props: {
                    //                    content: Number
                    //                    content: [String,Number]
                    content: {
                        type: String,
                        //                        required: false,
                        //                        default: ‘default Value‘,
                        //                        validator(value) {
                        //                            return(value.length > 5)
                        //                        }
                    }
                },
                template: ‘<div>{{content}}</div>‘
            })
            Vue.component(‘lastchild‘, {
                template: ‘<div>非Props特性</div>‘
            })
            var rm = new Vue({
                el: ‘#root‘
            })
        </script>
    </body>

</html>

 

Vue——组件参数校验与非Props特性

原文:https://www.cnblogs.com/Harold-Hua/p/11749896.html

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