正常的情況下render函數(shù)是這樣用的:
return h('div', {})
今天想用render函數(shù)返回自己寫(xiě)的vue component,想當(dāng)然地給第一個(gè)參數(shù)傳'my-component',結(jié)果一只報(bào)錯(cuò),正確做法應(yīng)該直接把component裝在在第一個(gè)參數(shù)上:
// 錯(cuò)誤做法
return h('my-component', {})
// 正確做法
return h(MyComponent, {})