Skip to content

Function h from vue can't render antd Components #4163

Closed
@BigDeep

Description

@BigDeep
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.1.4

Environment

os:macOS Vue:3.0.4

Reproduction link

https://github.com/vueComponent/ant-design-vue

Steps to reproduce

follow the step below

customRender: (data: unknown) => {
return h(
'a-button',
{
style: { cursor: 'pointer' },
onClick: () => {
console.log(data)
},
type: 'primary',
size: 'small',
},
'edit',
)
},

I found that i can't render a "a-button" , but i can render it while import {Button} from 'ant-design-vue' like below

import { Button } from 'ant-design-vue'
customRender: (data: unknown) => {
return h(
Button,
{
style: { cursor: 'pointer' },
onClick: () => {
console.log(data)
},
type: 'primary',
size: 'small',
},
'edit',
)
},

What is expected?

I had global inject antd ,but when i use ”h “ from vue i can't render an antd components by componentsName,
must import it and put it as a parameter into the function h

What is actually happening?

follow the step below

customRender: (data: unknown) => {
return h(
'a-button',
{
style: { cursor: 'pointer' },
onClick: () => {
console.log(data)
},
type: 'primary',
size: 'small',
},
'edit',
)
},

I found that i can't render a "a-button" , but i can render it while import {Button} from 'ant-design-vue' like below

import { Button } from 'ant-design-vue'
customRender: (data: unknown) => {
return h(
Button,
{
style: { cursor: 'pointer' },
onClick: () => {
console.log(data)
},
type: 'primary',
size: 'small',
},
'edit',
)
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions