老师,render里面不能用组件
来源:5-6 更加底层的 render 函数(选学)

目訫
2021-01-23
老师,帮忙看一下这个代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Render</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="el"></div>
</body>
<script>
// Render Function
const app = Vue.createApp({
template: `
<my-title1 />
`
})
app.component('Counter', {
render() {
const { h } = Vue
return h(`h1`, {}, 'Hello')
}
})
app.component('my-title1', {
render() {
const { h } = Vue
return h(Counter)
}
})
const vm = app.mount('#el')
</script>
</html>
会提示Counter找不到,可是如果加上单引号又会渲染成一个标签,老师帮忙解答一下,谢谢
写回答
1回答
-
return h(<Counter/>)
132021-01-24
相似问题