vue復(fù)合組件實(shí)現(xiàn)注冊表單功能
更新時(shí)間:2017年11月06日 11:08:05 作者:匿名的girl
這篇文章主要為大家詳細(xì)介紹了vue復(fù)合組件實(shí)現(xiàn)注冊表單功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了vue注冊表單的具體代碼,供大家參考,具體內(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è)就可以用引號或者``
template:'<p>源于純凈,歸于健康</p>'
})
Vue.component("my-article",{
//當(dāng)調(diào)用多個(gè)組件時(shí)要用``符號,而且要用頂層標(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="請輸入用戶名"/>
`
})
Vue.component("my-pwd",{
template:`
<label>密碼:</label>
`
})
Vue.component("pwd-input",{
template:`
<input type="text" placeholder="請輸入密碼"/>
`
})
Vue.component("my-login",{
template:`
<button>登錄</button>
`
})
Vue.component("my-resign",{
template:`
<button>注冊</button>
`
})
//復(fù)合組件作為根組件名字必須是烤串式的,駝峰的會報(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>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue在使用element組件出現(xiàn)<el-input>標(biāo)簽無法輸入的問題
這篇文章主要介紹了vue在使用element組件出現(xiàn)<el-input>標(biāo)簽無法輸入的問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04
vue跳轉(zhuǎn)頁簽傳參并查詢參數(shù)的保姆級教程
這篇文章主要介紹了vue跳轉(zhuǎn)頁簽傳參并查詢參數(shù)的保姆級教程,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-04-04
vue中使用jquery滑動到頁面底部的實(shí)現(xiàn)方式
這篇文章主要介紹了vue中使用jquery滑動到頁面底部的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12
vue集成kindeditor富文本的實(shí)現(xiàn)示例代碼
這篇文章主要介紹了vue集成kindeditor富文本的實(shí)現(xiàn)示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06

