naive-ui icon indicating copy to clipboard operation
naive-ui copied to clipboard

组件内使用NFormItemGi组件无法渲染、是否应该找内层的NFormItemGi组件

Open baicie opened this issue 1 year ago • 3 comments

问题的清晰而简明的描述

  1. 创建一个组件直接返回NFormItemGi 里面包个input啥的组件
  2. 在form组件中使用创建的组件
  3. 期望是渲染,可能是vnode没有去找嵌套的NFormItemGi组件

建议的解决方案

处理嵌套的NFormItemGi组件

备选方案

No response

附加上下文

No response

验证

  • [X] 阅读 贡献指南
  • [X] 阅读 文档
  • [X] 检查是否已经存在请求相同功能的问题,以避免创建重复的问题。

baicie avatar Jun 04 '24 06:06 baicie

提供的复现 最小可复现的示例

jahnli avatar Jun 04 '24 06:06 jahnli

提供的复现 最小可复现的示例

有点忙等下班哈哈

baicie avatar Jun 04 '24 06:06 baicie

提供的复现 最小可复现的示例

https://github.com/baicie/for-naiveui-form-item

baicie avatar Jun 06 '24 06:06 baicie

Provide a based on CodeSandbox or stackblitz [Minimal, Reproducible Example] (https://stackoverflow.com/help/minimal-reproducible-example)

jahnli avatar Oct 11 '24 15:10 jahnli

import { NForm, NFormItemGi, NGrid, NGridItem, NInput } from "naive-ui";
import { defineComponent } from "vue";
import Child from "./components/Com";

const App = defineComponent({
  setup() {
    return () => (
      <NForm
        labelPlacement="left"
        showFeedback={false}
        style={{ marginLeft: "50px" }}
      >
        <NGrid cols={24} xGap={20} yGap={20}>
          <NFormItemGi span={12}>
            <NInput />
          </NFormItemGi>

          <Child />
        </NGrid>
      </NForm>
    );
  },
});

export default App;

import { NFormItemGi, NInput } from "naive-ui";
import { defineComponent } from "vue";

const Child = defineComponent({
  setup() {
    return (
      <NFormItemGi span={6}>
        <NInput />
      </NFormItemGi>
    );
  },
});

export default Child;

baicie avatar Oct 12 '24 03:10 baicie

很有可能像 grid 一样, NForm 子元素只能是 NFormItem

jahnli avatar Oct 12 '24 03:10 jahnli

是这样的因为只找了一层没继续往下找 算是用法没用对 继续往下找也不现实

baicie avatar Oct 12 '24 03:10 baicie