LoginSignup
14
6

More than 5 years have passed since last update.

vue-router で絶対パス ( http 始まり ) を取得する

Last updated at Posted at 2018-11-24

router.resolve が用意されているので、それを使うだけ。

this.$router.resolve({
  name: 'ExmaplePage',
  params: {
    id: id
  }
}).href

これだけだと /example_page/1 のようになるので location.origin と組わせる。

const url = this.$router.resolve({
  name: 'ExmaplePage',
  params: {
    id: id
  }
}).href
location.origin + url.location

これで https://example.com/example_page/1 のようにできる。

14
6
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
14
6