最近在研究vue的路上,那么今天也算個學(xué)習(xí)筆記吧!
導(dǎo)航按鈕:
<div class="tab-title"> <p @click="a='tab1'"><router-link to='/collectnewcars'>新車</router-link><em></em></p> <p @click="a='tab2'"><router-link to='/collectusedcars'>二手車</router-link><em></em></p> <p @click="a='tab3'"><router-link to='/collectproducts'>車品</router-link></p> </div><div class="tabs"> <component is:="current"></component></div>
寫3個子組件分別為
<tab1></tab1><tab2></tab2><tab3></tab3>
js里面用局部組件引入這三個子組件
//數(shù)據(jù)里面data (){ return { a:'tab1' //默認(rèn)顯示tab1子組件 }}components:{ 'tab1':tab1, 'tab2':tab2, 'tab3':tab3}
如果要從父組件里面往這些字組件里面?zhèn)鲾?shù)據(jù),和普通的父組件-》子組件傳遞數(shù)據(jù)是一個道理,只不過在這個里面綁定一次屬性,就可以在每個子組件里面都接收到數(shù)據(jù),例如:
在子組件里面定義props:[]后,就可以接收到父組件傳來的方法,以及數(shù)據(jù)
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答