【问题标题】:make composed Link with react-router使用 react-router 制作组合链接
【发布时间】:2016-11-13 15:46:36
【问题描述】:

问题是当我添加一个组合链接时

<Route path="L1/L2" component={Comp}/>

导航到链接时,应用程序无法从公用文件夹加载资源,因为应用程序正在从示例加载资源:http://localhost:8080/L1/bundle.js 而不是 http://localhost:8080/bundle.js 我猜这是 webpack 配置中的问题,但无法修复 这是我的 webpack 配置:

    var config = {
      devtool: 'eval-source-map',
      entry:  __dirname + "/app/Index.js",
      output: {
       path: __dirname + "/public",
       filename: "bundle.js"
     },
     module: {
     loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel',
      query: {
        presets: ['es2015','react']
      }
    }]
   },
   devServer: {
    contentBase: "./public",
    colors: true,
    historyApiFallback: true,
    inline: true
   }

所有帮助将不胜感激提前谢谢您!

【问题讨论】:

    标签: reactjs webpack react-router


    【解决方案1】:

    这是关于你如何在 index.html 中加载你的包:

    • <script src="bundle.js"></script> 相对于当前网址

    • <script src="/bundle.js"></script> 相对于

    尝试第二个版本,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 2019-01-21
      • 2020-06-06
      • 2017-11-12
      • 1970-01-01
      • 1970-01-01
      • 2015-10-19
      • 2021-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多