如题:
官网Notification代码
import { Button, notification } from 'antd';
const openNotification = () => {
notification.open({
message: 'Notification Title',
description: 'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
onClick: () => {
console.log('Notification Clicked!');
},
});
};
ReactDOM.render(
<Button type="primary" onClick={openNotification}>Open the notification box</Button>,
mountNode
);
自己封装组件代码
import React from 'react'
import { Notification} from 'antd';
export default class Notifi extends React.Component {
constructor(props) {
super(props);
}
openNotification = () => {
console.log(`this.props.notification:${JSON.stringify(this.props)}`)
const {message,description} = this.props.notification
notification.open({
message: message,
description: description,
})
}
componentDidMount(){
this.openNotification()
}
render(){
return(<div></div>)
}
}
想问下为啥报ReferenceError: notification is not defined这个错误,感觉是this问题,但是没找到合适的解决方法
你写成大写了