king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/menu/components/code/sandbox/codecontent/index.jsx
@@ -1,13 +1,15 @@
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 = {
@@ -32,6 +34,18 @@
    }
  }
  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
@@ -47,6 +61,16 @@
        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() {