Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs ons导航器:错误:模块解析失败:意外令牌(330:6)_Reactjs_Webpack_Onsen Ui_Onsen Ui2 - Fatal编程技术网

Reactjs ons导航器:错误:模块解析失败:意外令牌(330:6)

Reactjs ons导航器:错误:模块解析失败:意外令牌(330:6),reactjs,webpack,onsen-ui,onsen-ui2,Reactjs,Webpack,Onsen Ui,Onsen Ui2,如何修复此错误?使用“react onsenui”库中的导航器组件时会发生此错误 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#l

如何修复此错误?使用“react onsenui”库中的导航器组件时会发生此错误

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>

此错误的原因是导航器组件的导入不正确。
错误:
从“react onsenui/src/components/Navigator”导入导航器
正确:
从'react onsenui'导入{Navigator}


IDE强制自动导入后添加了错误的导入。

欢迎使用StackOverflow,您能提供不起作用的组件吗?另外,您使用的是哪个版本的网页包?在Webpack 7中,一些预设和插件已经更新。
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'
            ]
          }
        }]
      }
...