Skip to content

ant-design-vue 在使用组件的时候编译报错 #542

@wuchaoya

Description

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

Version

1.3.5

Environment

mac 0.12.5 Chrome vue 2.6.6

Reproduction link

https://github.com/wuchaoya/vue-ts.git

Steps to reproduce

写在前面:
我的项目是用vue-cli创建的ts项目,在项目中我是以vue官网文档上基于类的vue组件。

import Vue, {CreateElement} from 'vue';
import Component from 'vue-class-component';
import {Layout, Button} from 'ant-design-vue';
import SiderMenu from '@/components/SiderMenu';
import Header from './Header';
import TopNavHeader from '@/components/TopNavHeader';
import './BasicLayout.less';

const {Content} = Layout;

@Component

export default class BasicLayout extends Vue  {

render (h: CreateElement) {
    return (
      <div>
        <Layout>
          <Header>
            <TopNavHeader />
          </Header>
          <Layout>
            <SiderMenu />
            <Layout>
              <Content>
                <Button type='primary'>按钮</Button>
              </Content>
            </Layout>
          </Layout>
        </Layout>
      </div>
    )
  }
}
}

如上面代码所示,在使用Button这个组件时候,我试图给Button组件一个type,结果就出现了一个错误:
Type '{ type: string; }' is not assignable to type 'ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'.
Property 'type' does not exist on type 'ComponentOptions<Vue, DefaultData, DefaultMethods, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'.

这个错误同样出现在ant-design-vue 的任意一个组件我去给它传递属性的时候,如传递一个class,style,size。

What is expected?

可以正常使用任何一个组件

What is actually happening?

组件无法传递任何属性

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions