我无法尝试发布节点模块,material-ui-next-datepicker
它在本地工作,但在作为节点模块安装时没有
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import {MuiThemeProvider, createMuiTheme, withStyles, StyledComponentProps, Theme} from 'material-ui/styles'
import DateFormatInput from 'material-ui-next-datepicker'
const theme = createMuiTheme()
const styles = (theme:Theme):Record<string, React.CSSProperties> => ({
container: {
width: '100vw',
height: '100vh',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}
})
@(withStyles as any)(styles)
class DemoPage extends React.Component<DemoPageProps, DemoPageState> {
constructor(props) {
super(props)
this.state = {
date: undefined
}
}
onChange = (date:Date) => {
console.log(date)
this.setState({date})
}
render() {
const {classes} = this.props
const {date} = this.state
return (
<div className={classes.container}>
<DateFormatInput name='date-input' value={date} onChange={this.onChange} label='Date'/>
</div>
)
}
}
interface DemoPageProps extends React.Props<{}>, StyledComponentProps {
}
interface DemoPageState {
date: Date
}
ReactDOM.render(
<MuiThemeProvider theme={theme}>
<DemoPage/>
</MuiThemeProvider>
, document.getElementById('root'))
当我打印出DateFormatInput时,它看起来很好......绝对不是未定义的
我不太熟悉依赖关系以及如何区分对等,环境或捆绑。所以,我确实需要一些帮助来使这个节点模块工作
答案 0 :(得分:0)
最后只需添加.npmignore
即可解决此问题我删除了所有的演示文件,如:
演示/
的src /
的index.html
tsconfig.json
webpack.config.js
然后通过导入......
开始正常工作