ReactJS和React路由器:PWA白页

时间:2020-11-09 11:02:47

标签: javascript reactjs webpack react-router

我正在使用 React JS 开发一个Web应用程序。当ppl在我的网站上时,一切正常。但是,当他们尝试将其应用程序添加到主屏幕时,就像他们为pwa所做的那样,它们会出现错误:确实,当他们添加具有这种路径http://website.com/group的页面时,会出现一个弹出白页。 我认为这是由于浏览器试图在http://website.com/group/main.js而不是http://website.com/main.js下获取javascript文件。

当我在浏览器中重新加载时,现在没有问题了。在这种类型的页面上重新加载时遇到了这个问题,但是我通过以下几种方法进行了修复:

  • index.html
  • 上添加“”
  • webpack.config.js
  • 中添加“ publicPath:'/'”

我的webpack.config.js文件

TypeError                                 Traceback (most recent call last)
<ipython-input-12-0c720eb43923> in <module>()
      1 engine2=sqlalchemy.create_engine('mysql+pyodbc://root:Johnny2010@localhost/sakila?DRIVER={MySQL ODBC 8.0 Unicode Driver}?charset=utf8')
----> 2 df.to_sql('test',engine2,index=False)

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py in to_sql(self, name, con, schema, if_exists, index, index_label, chunksize, dtype)
   2125         sql.to_sql(self, name, con, schema=schema, if_exists=if_exists,
   2126                    index=index, index_label=index_label, chunksize=chunksize,
-> 2127                    dtype=dtype)

C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\sql.py in to_sql(frame, name, con, schema, if_exists, index, index_label, chunksize, dtype)
    448     pandas_sql.to_sql(frame, name, if_exists=if_exists, index=index,
    449                       index_label=index_label, schema=schema,
--> 450                       chunksize=chunksize, dtype=dtype)


...
...

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py in _execute_context(self, dialect, constructor, statement, parameters, *args)
   1191                         statement,
   1192                         parameters,
-> 1193                         context)

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py in do_execute(self, cursor, statement, parameters, context)
    506     def do_execute(self, cursor, statement, parameters, context=None):
--> 507         cursor.execute(statement, parameters)

TypeError: The first argument to execute must be a string or unicode query.

我的路线:

const path = require('path');
const Dotenv = require('dotenv-webpack');

module.exports = {
    devServer: {
      historyApiFallback: true,
    },
    entry: './src/index.js',
    output: {
        filename: 'main.js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/'
    },
    module: {
        rules: [
            {
                test:  /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader',
                ]
            },
            {
                test: /\.(png|svg|jpg|gif)$/,
                use: [
                    'file-loader'
                ]
            },
            {
                test: /\.(woff|woff2|eot|ttf|otf)$/,
                use: [
                    'file-loader',
                ],
            }
        ]
    },
    plugins: [
        new Dotenv()
    ]
};

有什么主意吗? 非常感谢

0 个答案:

没有答案