Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

378
Views
VueRouter navigation to hash without # symbol?

I am using router-link to navigate over my Vue/Laravel8 single page app:

  <router-link :to="{ hash: 'about' }">About us</router-link>

This method unfortunately leaves an ugly # symbol in the url:

localhost:3000/#about

Is ther any conventient way to get rid of the #?^

Edit:

It was suggested to use history mode but this is a router link to hash. I have history mode enabled already but it doesn't remove the # from the url.

router.js:

import Vue from "vue";
import VueRouter from "vue-router";

import Home from "../vue/home";
import About from "../vue/about";

Vue.use(VueRouter);

export default new VueRouter ({
    mode: "history",
    routes: [
        {path: "/", name: "home", component: Home},
        {path: "/about", name: "about", component: About},
    ],
    scrollBehavior(to) {
        return {
            selector: to.hash,
            behavior: 'smooth'
        }
    }
});

web.php:

<?php

use Illuminate\Support\Facades\Route;


Route::get('/{any}', function () {
    return view('welcome');
})->where('any', '.*');
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

# means hash router, the hash router doesn't require HTML5 history API, which is convenient when you can't redirect every request to /index.html when you're building a single-page web app.

What you are looking for is BrowserRouter, which requires using HTML5 history API and requires you to redirect every request to /index.html in order to work, because it's a client router, not from a server.

const router = new VueRouter({
  mode: 'history',
  routes: [...]
})

Simply add mode: 'history' and you're using BrowserRouter now.

More: https://router.vuejs.org/guide/essentials/history-mode.html

about 4 years ago · Juan Pablo Isaza Report

0

You would actually just want to set mode to history:

const router = new VueRouter({
  mode: 'history'
})

make sure your server is configured to handle these links,though:

history mode

about 4 years ago · Juan Pablo Isaza Report

0

No. The hash sign is essential for using hash mode (hence why it is in the name). It indicates the start of the fragment identifier (which is used for in-page navigation).

If you didn't use the hash, then you've be using HTML5 history mode and navigating to a different path which would need to be handled by the server.

(As an aside, you might want to look at this answer which covers a similar question from the opposite direction for React).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!