码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-10-28 00:46:39      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:component   new   nbsp   def   校验   char   code   ida   http   

<!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特性

标签:component   new   nbsp   def   校验   char   code   ida   http   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!