2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Vue Router 直接URLでアクセスするとエラーが起きる

Last updated at Posted at 2020-07-08

Vue.jsを使っていて、通常の画面遷移のルーティングは問題無いがURLを直打ちすると

Uncaught SyntaxError: Unexpected token <

というエラーになってしまう現象が起きた。

:bomb: index.html内のパスの設定が原因

これを

<script type="text/javascript" src="js/app.js"></script>

このように変えてやるだけ

<script type="text/javascript" src="/js/app.js"></script>

上のパターンだと直接URLを叩いた時とリンクから画面遷移した時で見ている場所が変わってしまう。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?