本文實(shí)例為大家分享了vue注冊(cè)表單的具體代碼,供大家參考,具體內(nèi)容如下
<!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <script src="js/vue.js"></script> </head> <body> <div id="container"> <p>{{msg}}</p> <my-article></my-article> </div> <script> //要采用組件化的方式來編寫頁面, // 把任何一個(gè)可被重用的元素封裝成組件 // everything is component Vue.component("my-title",{ template:`<div> <h1>清風(fēng)手紙</h1> <h4>原木</h4> </div>` }) Vue.component("my-content",{ //一個(gè)就可以用引號(hào)或者`` template:'<p>源于純凈,歸于健康</p>' }) Vue.component("my-article",{ //當(dāng)調(diào)用多個(gè)組件時(shí)要用``符號(hào),而且要用頂層標(biāo)簽包含 template:` <div> <my-title></my-title> <my-content></my-content> </div> ` }) new Vue({ el:"#container", data:{ msg:"Hello VueJs" } }) </script> </body> </html>
<!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <script src="js/vue.js"></script> </head> <body> <div id="container"> <p>{{msg}}</p> <!--調(diào)用根組件 --> <my-form></my-form> </div> <script> //創(chuàng)建組件my-user Vue.component("my-user",{ template:` <label>用戶名:</label> ` }) Vue.component("user-input",{ template:` <input type="text" placeholder="請(qǐng)輸入用戶名"/> ` }) Vue.component("my-pwd",{ template:` <label>密碼:</label> ` }) Vue.component("pwd-input",{ template:` <input type="text" placeholder="請(qǐng)輸入密碼"/> ` }) Vue.component("my-login",{ template:` <button>登錄</button> ` }) Vue.component("my-resign",{ template:` <button>注冊(cè)</button> ` }) //復(fù)合組件作為根組件名字必須是烤串式的,駝峰的會(huì)報(bào)錯(cuò) Vue.component("my-form",{ //可以用table、form、div等…… template:` <form> <my-user></my-user> <user-input></user-input> <br> <my-pwd></my-pwd> <pwd-input></pwd-input> <br> <my-resign></my-resign> <my-login></my-login> //寫法或者 <my-login/> </form> ` }) new Vue({ el:"#container", data:{ msg:"Hello VueJs" } }) </script> </body> </html>
Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號(hào)-2
違法及侵權(quán)請(qǐng)聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市萬商天勤律師事務(wù)所王興未律師提供法律服務(wù)