
组件引入的2种方法:
- :is=“com-a” (优点:可以动态引入)
- <com-a></com-a>
父组件和子组件之间的传递方式:

slot插槽的使用
<com-a>
<p> 123 </p>
</com-a>
<slot></slot>
//这里的slot可以设置默认值 eg:<slot>default slot</slot>
//slot中有name属性,eg:
<slot name="header"></slot>
//other js
<com-a>
<p slot="header"></p>
</com-a>
keep-alive
keep-alive 内置标签
打个比方,可以这样理解:目前有a和b 2个组件,我如果从a组件 切换到 b组件,这时候 a组件已经被缓存了,如果下次再切换到 a组件,加载速度就会快一点,这就是keep-alive的作用。
子组件 emit ,父组件来接受。
总结:

网友评论