Jus*_*gin 2 javascript css twitter-bootstrap reactjs react-bootstrap
我正在使用react-bootstrapNPM包来使我的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>
);
}
}
Run Code Online (Sandbox Code Playgroud)
改为:
import { bootstrapUtils } from 'react-bootstrap/lib/utils';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2414 次 |
| 最近记录: |