// 使用 Vue 3 的 h 函数创建 VNode
import { h, render } from 'vue';
// 创建一个简单的 VNode
const vnode = h('div', { class: 'container' }, [
h('h1', null, 'Hello Vue 3!'),
h('p', null, 'This is a paragraph created using the h function.')
]);
// 将 VNode 渲染到 DOM 中
const container = document.getElementById('app');
render(vnode, container);
// 解释说明:
// h 函数是 Vue 3 中用于创建虚拟 DOM (VNode) 的函数。它接受三个参数:
// 1. 类型:可以是一个字符串(HTML 标签名)或组件定义。
// 2. 属性对象:包含元素的属性、样式、事件监听器等。
// 3. 子节点:可以是字符串、数组或其他 VNode。
上一篇:element vue
下一篇:vue3 ref获取dom
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站