【发布时间】:2020-02-27 05:58:15
【问题描述】:
如何解决这个错误?使用“react-onsenui”库中的 Navigator 组件时会出现此错误。
Error: Module parse failed: Unexpected token (330:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| return (
> <ons-navigator { ...attrs } ref={(navi) => { this._navi = navi; }}>
| {pages}
| </ons-navigator>
部分 Webpack.config.js 代码:
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, 'src'),
use: [{
loader: 'babel-loader',
options: {
presets: ['react', 'env'],
plugins: [
'react-hot-loader/babel',
'transform-class-properties',
'transform-object-rest-spread'
]
}
}]
}
...
【问题讨论】:
-
欢迎使用 StackOverflow,您能否提供不起作用的组件?另外,您使用的是哪个版本的 Webpack?在 Webpack 7 中,一些预设和插件已经更新。
标签: reactjs webpack onsen-ui onsen-ui2