---
title: "Vue Router v4.xでハッシュ履歴（相対パス）指定を行う"
description: "BoundWorksのNOTE「Vue Router v4.xでハッシュ履歴（相対パス）指定を行う」。2021-06-19公開。"
url: "https://boundworks.net/vue-router-v4-createwebhashhistory/"
language: "ja"
date: "2021-06-19"
---

# Vue Router v4.xでハッシュ履歴（相対パス）指定を行う

公開: 2021-06-19

![アイキャッチ画像](https://boundworks.net/images/b6b2c126386d6d96da99ecc51daae7c8.png)

Vue Router v 4.xで、サーバーを利用しない（file://）場合などに、Vue.jsをHTML履歴ではなく、ハッシュ履歴で使いたい場合は、`src/router/index.js|ts`に、

```
const router = createRouter({
  history: createWebHashHistory('./'),
  routes
})
```

と記載するとローカルファイルのHTMLでもルーティングを利用することができます。

公式ドキュメントは[https://next.router.vuejs.org/api/#createwebhashhistory](https://next.router.vuejs.org/api/#createwebhashhistory) に記載があります。
