先来一个按钮组件使用的对比,官方文档的(不能直接用)和实际能用的。
官网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 =>
),{
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(
自己写的:
<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 =>
),{
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.导出类
原文链接:/antdesign/58113.html