Skip to content
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

NTabs 组件出现警告提示 'Slot "default" invoked outside of the render function' #3134

Closed
angeltxwh opened this issue Jun 19, 2022 · 6 comments
Labels
untriaged need to sort

Comments

@angeltxwh
Copy link

angeltxwh commented Jun 19, 2022

TuSimple/naive-ui version (版本)

2.30.4

Vue version (Vue 版本)

3.2.37

Browser and its version (浏览器及其版本)

102.0.5005.115

System and its version (系统及其版本)

Windows 11

Node version (Node 版本)

Reappearance link (重现链接)

暂无

Reappearance steps (重现步骤)

import {  defineComponent, h } from "vue";
import { NTabPane, NTabs } from "naive-ui";

export default defineComponent({
	render() {
		return [
			h(NTabs, { type: "line", animated: true }, () => {
				return h(NTabPane, { name: "base", tab: "基础信息" }, () => [])
			}),
			h(NTabs, { type: "line", animated: true }, () => [
				h(NTabPane, { name: "base", tab: "基础信息" }, () => [])
			]),
			h(NTabs, { type: "line", animated: true }, {
				default: () => h(NTabPane, { name: "base", tab: "基础信息" }, () => [])
			}),

		]
	},
})

Expected results (期望的结果)

不报错就好

Actual results (实际的结果)

[Vue warn]: Slot "default" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead. 
setup	@	Tabs.js:56

Remarks (补充说明)

我是用ts文件写的VUE组件,搜了issue发现有人提了同样的问题但是被归咎为他的使用方式有问题。但是我觉着这个问题是真的存在的, 我上面用各种写法试了一下,他都会报警告的。

@github-actions github-actions bot added the untriaged need to sort label Jun 19, 2022
@07akioni
Copy link
Collaborator

07akioni commented Jun 19, 2022

你可以加一个 defaultValue,可以避免这个问题

@07akioni
Copy link
Collaborator

会改一下文档

@angeltxwh
Copy link
Author

@07akioni 好的,谢谢老板

@coader
Copy link

coader commented Jul 11, 2022

这个问题如何解决的 我用 ()=>... 或 {default:()=>...}都不行

@coader
Copy link

coader commented Jul 11, 2022

哦 加了个defaultValue的属性指定

@07akioni
Copy link
Collaborator

哦 加了个defaultValue的属性指定

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged need to sort
Projects
None yet
Development

No branches or pull requests

3 participants