gpt4 book ai didi

meteor - Material-ui 错误(缺少类属性转换。)

转载 作者:行者123 更新时间:2023-12-03 14:21:26 26 4
gpt4 key购买 nike

我一直在尝试使用react-mounter在Meteor中设置material-ui主题来安装组件。

我在设置它时遇到问题,然后我扩展了该组件,以便我可以使用material-ui 网站上的示例设置主题。

我现在收到以下错误消息。

client/components/navbar.jsx:14:4:/client/components/navbar.jsx:丢失 类属性转换。

这是导航栏示例代码

import React from 'react';
import AppBar from 'material-ui/AppBar';
import IconButton from 'material-ui/IconButton';
import Navigationclose from 'material-ui/svg-icons/navigation/close';
import IconMenu from 'material-ui/IconMenu';
import NavigationMoreVert from 'material-ui/svg-icons/navigation/more-vert';
import MenuItem from 'material-ui/MenuItem';
import baseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import getMuiTheme from 'material-ui/styles/getMuiTheme';


class Navbar extends React.Component {

childContextTypes: {
muiTheme: React.PropTypes.object.isRequired
}

getChildContext() {
return {muiTheme: getMuiTheme(baseTheme)};
}

render() {

return (<AppBar
title="Title"
iconElementLeft={<IconButton><Navigationclose /></IconButton>}
iconElementRight={
<IconMenu
iconButtonElement={
<IconButton><NavigationMoreVert /></IconButton>
}
targetOrigin={{horizontal: 'right', vertical: 'top'}}
anchorOrigin={{horizontal: 'right', vertical: 'top'}}
>
<MenuItem primaryText="Refresh"/>
<MenuItem primaryText="Help"/>
<MenuItem primaryText="Sign out"/>
</IconMenu>
}
/>);
}
}


export default Navbar;

这是 router.jsx

import React from 'react';
import {mount} from 'react-mounter';
import {MainLayout} from '/client/layouts/mainLayout.jsx';
import Content from '/client/components/content.jsx';
import Navbar from '/client/components/navbar.jsx';
import Footer from '/client/components/footer.jsx';

FlowRouter.route("/", {
action () {
mount(MainLayout, {
navbar: <Navbar/>,
content: <Content/>,
footer: <Footer/>
});
}
});

最佳答案

你需要一个 Babel 变换。 Meteor 1.3.3+ 通过 .babelrc 支持其他插件和预设

安装静态转换:

npm install babel-plugin-transform-class-properties

# .babelrc
{
"presets": [
"meteor",
"es2015",
"stage-1"
],

"plugins": [
"transform-class-properties"
]
}

Support in Meteor 1.3.3

The transform

关于meteor - Material-ui 错误(缺少类属性转换。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36852474/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com