可以让网友帮做任务的网站,青岛网上房地产网签查询,新手如何搭建自己的网站,展馆设计总结vue3渲染函数h的简单使用
基本用法
创建 Vnodes Vue 提供了一个 h() 函数用于创建 vnodes#xff1a;
import { h } from vueconst vnode h(div, // type{ id: foo, class: bar }, // props[/* children */]
)更多用法
详情查看官方文档
在SFC中定义局部组件使用
h函数…vue3渲染函数h的简单使用
基本用法
创建 Vnodes Vue 提供了一个 h() 函数用于创建 vnodes
import { h } from vueconst vnode h(div, // type{ id: foo, class: bar }, // props[/* children */]
)更多用法
详情查看官方文档
在SFC中定义局部组件使用
h函数返回的是 Vnodes无法直接在template使用需要用一个组件render接收
示例
vue组件是一个对象在setup中定义局部组件基本等于定义一个对象按照vue组件文件对象的格式来定义。
templatedivdivcount: {{ count }}/divTextComp msghello/TextComp/div
/templatescript setup langts
import { ref, h } from vueconst count ref(0)
const TextComp {props: [msg],setup(props, context) {return () {return h(div, {class: container,onClick: () {console.log(props, props)}}, [props.msg,h(button, {onClick: () {count.value}}, increase)])}}
}/scriptstyle scoped/style