最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Handling dot in vue-router params using vue 3 - Stack Overflow

programmeradmin0浏览0评论

If route params contains dot(.) vue redirect the route to 404. In vue 2 we can allow/handle dot in router params using following rule in webpack:

devServer: {
      historyApiFallback: {
          disableDotRule: true
      }
 }

But vue 3 use vite instead of webpack. How to handle dot in parameters now?

route example are following:

{
  path: your-route/:params",
  ponent: someponent,
}

If route params contains dot(.) vue redirect the route to 404. In vue 2 we can allow/handle dot in router params using following rule in webpack:

devServer: {
      historyApiFallback: {
          disableDotRule: true
      }
 }

But vue 3 use vite instead of webpack. How to handle dot in parameters now?

route example are following:

{
  path: your-route/:params",
  ponent: someponent,
}
Share Improve this question asked Feb 8, 2022 at 6:30 JustAnotherUserJustAnotherUser 535 bronze badges 1
  • It's usually best to go to the official source first instead of asking here. See github./vitejs/vite/issues/4344 – Phil Commented Feb 8, 2022 at 6:37
Add a ment  | 

2 Answers 2

Reset to default 10

I had the same problem and based on one of the question ments I went to the github issue about this problem and they remend a plugin for vite that solves it.

Install it with

npm install --save-dev vite-plugin-rewrite-all

And add it to vite.config.js

import pluginRewriteAll from 'vite-plugin-rewrite-all';

export default {
  plugins: [pluginRewriteAll()]
}

Check out the github issue https://github./vitejs/vite/issues/4344

And the plugin's github https://github./ivesia/vite-plugin-rewrite-all.

Vite 5 allows dots in URL params without the need for any plugins. It's mentioned here in this thread.

You can update to Vite 5 with

npm install -D vite@latest
发布评论

评论列表(0)

  1. 暂无评论