-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datatable请求提供对外的列插槽,或者render提供jsx的形式,不必使用h函数 #5134
Comments
臣附议 |
本来想搜别的,居然让我看到个刚刚自己解决掉的 issue.... |
感谢大佬,我去搜索了一下 vite + vue3使用jsx,得到了更好的解决办法,希望可以在文档里面补充一下,要不我这种笨蛋就很容易因为这个弃坑~ |
补充一下,如果使用 任何在 import { defineConfig } from "vue"
import Jsx from '@vitejs/plugin-vue-jsx'
export default defineConfig({
plugins: [
// 省略你的其他插件
Jsx() // 注册 jsx 插件
]
}) 然后就可以在 <script setup lang="jsx">
import { NButton } from "naive-ui"
const foo = <div>foo</div>
const config = {
title: '操作',
key: 'actions',
useSlot: true,
render(row) {
// 也支持 render 直接返回
return <NButton>The front of the car is still smoking</NButton>
}
}
</script>
<template>
<!-- 支持直接渲染 -->
<foo />
</template> |
那插槽那种有解决的办法吗?表单的配置写在页面上,总觉得一堆常量配置页面中太麻烦,一写好多的。之前二次封装elementUi、ant design,都是通过插槽去渲染操作列,在父组件处理。 |
毛遂自荐 @skit/x.naive-ui,基于 Naive-UI 二次封装了 DataTable 组件,支持插槽式的写法。 |
duplicate #4273 |
This function solves the problem (这个功能解决的问题)
当我想要对列进行自定义的时候,目前我只能使用h函数进行自定义,但是如果遇到一些列,里面可能填充很多其他的组件,比如hover显示更多信息啥的,单纯使用h函数,确实是有点痛苦
最简单就是提供 基于 key 的插槽名字,或者render函数可以支持 jsx的写法,这样做可以简化我想要自定义列元素的写法
Expected API (期望的 API)
The text was updated successfully, but these errors were encountered: