特点:
- 无状态
- 本身没有实例(没有this)
- 没有生命周期
- 只接受处理传过来的数据
优点
渲染开销低 速度快
demo
`import Alert from '../components/AlertCom.vue'
import { h, render } from 'vue'
export const openAlert = () => {
const vNode = h(Alert)
const container = document.createElement('div')
document.body.appendChild(container)
render(vNode, container)
setTimeout(() => {
document.body.removeChild(container)
}, 2000)
}`