我在项目中使用React和MaterialUI。我想知道如何导入这个
var RaisedButton = mui.RaisedButton,
ThemeManager = new mui.Styles.ThemeManager();
到ES6
这就是我到目前为止的方式
import React from "react";
import { Link } from "react-router";
import ReactLogo from "elements/ReactLogo";
import mui from 'material-ui';
var RaisedButton = mui.RaisedButton,
ThemeManager = new mui.Styles.ThemeManager();
答案 0 :(得分:6)
你走了:
#include <iostream>
#include <string>
class dog {
public:
explicit dog(std::string name) : mname(name) {} // use initializer list
private:
std::string mname;
};
void Foo(dog g) {}
int main()
{
std::string name = "fido";
Foo(name);
}
MDN docs应该可以帮助您更好地了解es6导入。
答案 1 :(得分:0)
随着es6和es7的引入,语法正在快速改变。试试这个。
import React from 'react'; import Message from './Message.jsx';
>
> export default class MessageList extends React.Component{
> constructor(){ super(); this.state = {
> messages: [
> 'Hi Ignatius',
> 'Hello Jessy'
> ]
> }; }
>
> render(){ var messageNodes = this.state.messages.map((message)=> {
> return (
> <Message message={message}/>
> );
> });
>
>
> return (
> <div>{messageNodes}</div>
> ); } }