- 动态组件
- 动态组件就是 component组件 , 组件身上可以绑定一个is属性, 用来表示某一个组件
- is属性
- 我们html中有一些标签是规定它的直接子元素的 , 比如 ul li ol li selector option table这类型标签
- 不能直接用常规的组件使用方式, 必须在对应直接子元素上绑定 is属性
<div id="app">
<table>
<tr>
<td>aa</td>
<td>bb</td>
<td>cc</td>
</tr>
<tr is = 'my-table'></tr>
</table>
</div>
- keep-alive组件
将组件的内容存在浏览器缓存中, 当我们需要重复渲染的时候, 就从浏览器缓存中去调用,这样可以减少性能消耗
<keep-alive>
<component is = "A"></component>
</keep-alive>
- 不常用指令
- v-text vs v-html
- 都是用来将数据插入DOM中, 但是v-html可以解析标签类型数据
- v-cloak 解决 {{}} 语法短暂原样输出
- v-pre 原样输出
- v-once 只渲染一次
- 异步组件
- 异步组件也是一个函数, 只不过这个函数使用Promise,函数有一个返回值
<div id="app">
<async-com></async-com>
</div>
var result = new Promise(function( resolve, reject ){
resolve({
template: '<div> 异步组件 </div>'
})
})
Vue.component('AsyncCom',async () => {
const tpl = await result.then( res => res)
return tpl
})
new Vue({
el: '#app'
})