 attrs中被收集  , 继承属性和事件 只需要 <div v-bind="$attrs"></div>
attrs中被收集  , 继承属性和事件 只需要 <div v-bind="$attrs"></div>
 attrs,而是收集到
attrs,而是收集到 attrs" v-on="$listeners"></div>
attrs" v-on="$listeners"></div>
<!DOCTYPE html>
<html lang= en >
<head>
    <meta charset= UTF-8 >
    <meta name= viewport  content= width=device-width, initial-scale=1.0 >
    <title>Document</title>
    <script src= ./js/vue.global.js ></script>
</head>
<body>
    <div id= app >
    </div>
    <script>
        const app = Vue.createApp({
            template: `
                <base-input 
                    label="用户姓名" 
                    type="text" 
                    placeholder="username" 
                    maxlength="2" readonly 
                    @focus="onFocus"
                    />
               <base-input label="用户密码" type="password" placeholder=" password" maxlength="3" />
            `,
            data() {
                return {
                }
            }
        })
        app.component("base-input", {
            // props: ["label", "type", "placeholder", "maxlength"],
            // props:["label","type"], // 一个两个可以使用,多个就太多了,Vue3没用到的存在$attrs中,包括事件,Vue2事件是存在$listeners中,事件继承需要v-on="$listeners"
            props:["label"],
        //     template: `
        //         <div>
        //             <label>
        //             <span>{{ label }}: </span>
        //             <input
        //                 :type="type"
        //                 />
        //             </label>
        //         </div>
        // `,
            template: `
                <div>
                    <label>
                    <span>{{ label }}: </span>
                    <input
                        v-bind="$attrs"
                        />
                    </label>
                </div>
        `,
        })
        app.mount( #app )
    </script>
</body>
</html>