Ant Design 入门-参照官方文档使用组件

先来一个按钮组件使用的对比,官方文档的(不能直接用)和实际能用的。

官网demo:

<pre class="has">
import { Table,Divider,Tag } from 'antd';

const columns = [{
title: 'Name',dataIndex: 'name',key: 'name',render: text => <a href="javascript:;">{text},},{
title: 'Age',dataIndex: 'age',key: 'age',{
title: 'Address',dataIndex: 'address',key: 'address',{
title: 'Tags',key: 'tags',dataIndex: 'tags',render: tags => (

{tags.map(tag => {tag})}

),{
title: 'Action',key: 'action',render: (text,record) => (

<a href="javascript:;">Invite {record.name}

),}];

const data = [{
key: '1',name: 'John Brown',age: 32,address: 'New York No. 1 Lake Park',tags: ['nice','developer'],{
key: '2',name: 'Jim Green',age: 42,address: 'London No. 1 Lake Park',tags: ['loser'],{
key: '3',name: 'Joe Black',address: 'Sidney No. 1 Lake Park',tags: ['cool','teacher'],}];

ReactDOM.render(

,mountNode);

自己写的:

<pre class="has">
import { Table,Tag } from 'antd';
import React,{ Component } from 'react';
export default class MiniappList extends Component {
render() {
const columns = [{
title: 'Name',{
title: 'Tags',render: tags => (

{tags.map(tag => {tag})}

),{
title: 'Action',record) => (

<a href="javascript:;">Invite {record.name}

),}];
const data = [{
  key: '1',{
  key: '2',}];
return(<Table columns={columns} dataSource={data} />);

}
}

自己写的和文档的区别:

1. 需要引用react并且继承Component

2.导出类

3.使用 Component 的 render 函数标签放到 return 里面    -----完成

相关文章

``` rules: [ {required: true, message: &#39;请输入姓名&#39;}, {max: 16, message: &#3...
找到package.json文件,找到图位置加 port即可。
产生这个报错的原因是我当时将样式写到了less文件,我在div中使用的使用应该是使用className = ,而我误...
首先是安装 在index.js中引入样式 跟着官网点组件 import React,{Component} from &#39;react&...
本篇文章主要包含的内容有三个方面。 第一、Ant Design Pro简介; 第二、Ant Design Pro能做什么; 第三、...
在使用&#160;RangePicker 前正常,引入RangePicker 后报如下错误: 但是我项目中并没有使用hook,按...