首页 > 其他 > 详细

react 简单的用函数调出ui显示

时间:2018-10-30 23:25:33      阅读:187      评论:0      收藏:0      [点我收藏+]
import test from '../components/test'

const info = () => {
  test.info('This is a normal message');
};

render(){
retrun  <button onClick={info}>click me</button>
}

test.js

import React, { Component } from "react";
import ReactDOM from "react-dom";
import { Dialog, DialogTitle } from "@material-ui/core";

const Alert = (props) => (
  <Dialog open={true} fullWidth>
    <DialogTitle>{props.msg}</DialogTitle>
  </Dialog>
);

class Test extends Component {
  static info(msg) {
    const div = document.createElement("div");
    document.body.append(div);
    ReactDOM.render(<Alert msg={msg}/>, div);
  }
}
export default Test;

react 简单的用函数调出ui显示

原文:https://www.cnblogs.com/ajanuw/p/9880233.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!