我有一种情况,我有一个渲染功能,将一些数据传递到作用域槽.作为这个数据的一部分,我想包括一些由渲染函数构造的VNode,它可以选择由作用域槽使用.无论如何在模板中写入作用域槽以输出收到的原始VNode?
给定一个 VueJSVNode对象,我如何获取渲染后会生成的 HTML 元素?
例如:
> temp1
VNode {tag: "h1", data: undefined, children: Array(1), text: undefined, elm: undefined, …}
> temp1.children[0]
VNode {tag: undefined, data: undefined, children: undefined, text: "Test", elm: undefined, …}
> doSomething(temp1)
<h1>Test</h1>
Run Code Online (Sandbox Code Playgroud)
我正在尝试围绕DataTables.net库构建一个小的 VueJS 包装器。
为了在我的标记中模仿 HTML 表的行为,我需要如下内容:
<datatable>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<datatable-row v-for="person in people">
<td>{{ person.name }}</td>
<td>{{ person.age }}</td>
<td>{{ person.salary }}</td>
</datatable-row>
</tbody>
</datatable>
Run Code Online (Sandbox Code Playgroud)
我已经开始按如下方式实施:
数据表.vue
<template>
<table ref="table" class="display …Run Code Online (Sandbox Code Playgroud)