国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

vue組件中實(shí)現(xiàn)嵌套子組件案例

瀏覽:162日期:2022-12-01 18:10:21

如何把一個(gè)子組件comment.vue放到一個(gè)組件中去

1、先創(chuàng)建一個(gè)單獨(dú)的 comment.vue 組件模板

<template> <div class='cmt-container'> <h3>發(fā)表評(píng)論</h3> <hr> <textarea placeholder='請輸入要BB的內(nèi)容(最多吐槽120字)' maxlength='120'></textarea> <mt-button type='primary' size='large'>發(fā)表評(píng)論</mt-button> <div class='cmt-list'> <div class='cmt-item'><div class='cmt-title'> 第1樓&nbsp;&nbsp;用戶:匿名用戶&nbsp;&nbsp;發(fā)表時(shí)間:2012-12-12 12:12:12</div><div class='cmt-body'> 鋤禾日當(dāng)午 符合</div> </div> <div class='cmt-item'><div class='cmt-title'> 第1樓&nbsp;&nbsp;用戶:匿名用戶&nbsp;&nbsp;發(fā)表時(shí)間:2012-12-12 12:12:12</div><div class='cmt-body'> 鋤禾日當(dāng)午 符合</div> </div> <div class='cmt-item'><div class='cmt-title'> 第1樓&nbsp;&nbsp;用戶:匿名用戶&nbsp;&nbsp;發(fā)表時(shí)間:2012-12-12 12:12:12</div><div class='cmt-body'> 鋤禾日當(dāng)午 符合</div> </div> </div> <mt-button type='danger' size='large' plain>加載更多</mt-button> </div></template><script> </script><style lang='scss' scoped>.cmt-container{ h3{ font-size: 18px; } textarea{ font-size: 14px; height: 85px; margin: 0; } .cmt-list{ margin: 5px 0; .cmt-item{ font-size: 13px; .cmt-title{background-color: #ccc; } } .cmt-body{ line-height: 35px; text-indent: 2em; //縮進(jìn) } }} </style>

2、在需要使用組件的 頁面中,先手動(dòng)導(dǎo)入 comment 組件

+ import comment from ’./comment.vue’

3、在父組件中,使用’components’ 屬性,將剛才導(dǎo)入的 comment 組件,注冊為自己的 子組件

4、將注冊子組件時(shí)候的,注冊名稱,以 標(biāo)簽形式,在頁面中引用即可

vue組件中實(shí)現(xiàn)嵌套子組件案例

補(bǔ)充知識(shí):vue怎么將一個(gè)組件引入另一個(gè)組件?

項(xiàng)目是由的vue-cli搭建

1.這里有兩個(gè)組件,需求是把newComponents.vue里面的東西引入到helloWorld里面

vue組件中實(shí)現(xiàn)嵌套子組件案例

2.index.js里面的配置

vue組件中實(shí)現(xiàn)嵌套子組件案例

3.newComponents里面的內(nèi)容

vue組件中實(shí)現(xiàn)嵌套子組件案例

4.怎么將newComponents引入到helloWorld呢?

vue組件中實(shí)現(xiàn)嵌套子組件案例

5.頁面展示

vue組件中實(shí)現(xiàn)嵌套子組件案例

以上這篇vue組件中實(shí)現(xiàn)嵌套子組件案例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 海口市| 陵川县| 邻水| 德庆县| 枣强县| 和林格尔县| 土默特右旗| 海安县| 乌审旗| 张家港市| 大英县| 南京市| 武定县| 清水河县| 莒南县| 措美县| 金乡县| 长兴县| 象州县| 蒙山县| 顺义区| 巴中市| 泰兴市| 肇源县| 平顶山市| 曲水县| 邵武市| 当涂县| 汤阴县| 红原县| 吉木乃县| 石家庄市| 盖州市| 崇义县| 梅河口市| 隆昌县| 方城县| 遂宁市| 丹寨县| 乌拉特前旗| 辽阳市|