0

Using Vue 2.6.14, Vue Router set to history mode, URL containing a hashtag "#" breaks dynamic path.

const router = new VueRouter({
  base: `${process.env.VUE_APP_PUBLIC_PATH}`,
  mode: 'history',
  routes: [
    {
      path: '/document/:documentId(.*)',
      name: 'Document',
      component: Document,
      props: true
    },
    {
      path: '*',
      name: 'NotFound',
      component: NotFound
    }
  ]
});

URL ending in "/document/#1" returns as empty string for the "documentId" prop.

1 Answer 1

0
documentIdHashtagProof() { return this.documentId ? this.documentId : this.$route.hash; }

The problem was that the dynamic prop "documentId" was returning empty string and I've solved it by using a computed property that reads the hash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.