Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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
Express Vue路由器无法捕获网页包模板中带有点的路由_Express_Webpack_Vue Router - Fatal编程技术网

Express Vue路由器无法捕获网页包模板中带有点的路由

Express Vue路由器无法捕获网页包模板中带有点的路由,express,webpack,vue-router,Express,Webpack,Vue Router,我从启动应用程序,并将路由/edit/:filename添加到其中 问题是,包含点的文件名由Express处理,而不是由我的Vue应用程序处理 换句话说,/edit/123与路线匹配,但/edit/123.json或/edit/123.txt不匹配,我从Express获得了404 如何匹配路线中的任何内容或至少/edit/anyfilename.json?我在Vue论坛上有一个from。Vue使用connect history api fallback将所有HTTP请求重定向到index.htm

我从启动应用程序,并将路由
/edit/:filename
添加到其中

问题是,包含点的文件名由Express处理,而不是由我的Vue应用程序处理

换句话说,
/edit/123
与路线匹配,但
/edit/123.json
/edit/123.txt
不匹配,我从Express获得了404

如何匹配路线中的任何内容或至少
/edit/anyfilename.json

我在Vue论坛上有一个from。Vue使用
connect history api fallback
将所有HTTP请求重定向到
index.html
。除非
disableDotRule
设置为
true
,否则它将跳过路径中带有点的HTTP请求。正确的配置是

app.use(require('connect-history-api-fallback')({
  disableDotRule: true,
  rewrites: [
    {from: /\/app.js/, to: '/app.js'}
  ]
}))
请注意,我们必须为
/app.js
添加额外的重写,以便它不会重定向到
index.html