我正在使用react-bootstrap
NPM软件包使React
组件看起来正确。我需要自定义其中的一些,因此我遵循官方的React-Bootstrap文档,但是代码抛出错误index.jsx:5 Uncaught TypeError: Cannot read property 'addStyle' of undefined
。
这是我的自定义Button
组件代码:
import React from "react";
import Button from 'react-bootstrap/lib/Button';
import bootstrapUtils from 'react-bootstrap/lib/utils/bootstrapUtils';
bootstrapUtils.addStyle(Button, 'custom');
export default class MediaItemButton extends React.Component {
render() {
return (
<div>
<style type="text/css">{`
.btn-custom {
background-color: purple;
color: white;
}
`}</style>
<Button bsStyle="primary">Custom</Button>
</div>
);
}
}
更改为此:
import { bootstrapUtils } from 'react-bootstrap/lib/utils';
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句