| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Empty } from 'antd' |
| | | import { Empty, message } from 'antd' |
| | | |
| | | import './index.scss' |
| | | |
| | | class BraftContent extends Component { |
| | | static propTpyes = { |
| | | name: PropTypes.string, |
| | | html: PropTypes.any, |
| | | css: PropTypes.any, |
| | | js: PropTypes.any, |
| | | } |
| | | |
| | | state = { |
| | |
| | | } |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { js, name } = this.props |
| | | if (js) { |
| | | try { |
| | | // eslint-disable-next-line no-eval |
| | | eval(js) |
| | | } catch (e) { |
| | | message.warning(name + 'JS 执行失败!') |
| | | } |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (this.props.css !== nextProps.css) { |
| | | const { csselement } = this.state |
| | |
| | | this.setState({csselement: ele}) |
| | | } |
| | | } |
| | | if (this.props.html !== nextProps.html || this.props.js !== nextProps.js) { |
| | | if (nextProps.js) { |
| | | try { |
| | | // eslint-disable-next-line no-eval |
| | | eval(nextProps.js) |
| | | } catch (e) { |
| | | message.warning(nextProps.name + 'JS 执行失败!') |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | render() { |