Giter Club home page Giter Club logo

Comments (1)

HeskeyBaozi avatar HeskeyBaozi commented on June 17, 2024

@ArtD1 因为vue-router的模式选择的是hash,所以会在URL出现#符号。

如果不想要很丑的#符号,你则只需要修改这一行的代码

修改成

 mode: 'history'

即可。vue-router相关文档:HTML5 History 模式

要使其生效的具体做法是,重新编译主题,在themes\lite目录下运行命令

npm install # 这一步用来安装主题依赖

修改路由模式

// /src/router/index.ts
// 原来为 mode: 'hash'
mode: 'history'

编译主题:

npm run build

完成后,回到根目录

hexo g 
hexo s # 在localhost:4000预览

此时,则你会看到#符号已经去掉。

但是,不推荐这么做,因为如果后端不配置相关的history api fallback,则会导致出现404 Not found,除非你在后端配置如下逻辑:如果 URL 匹配不到任何静态资源,则应该返回同一个 index.html 页面

由于该主题大多都是使用github pages托管静态页面,无法进行相关配置,所以使用带#hash模式成为了第一选择。

但是我真的觉得很丑想去掉怎么办?

我会在后续的开发中实现整个应用基于hexo的静态化,具体做法是是使用服务端渲染。但在现在,仍然会使用hash模式。

from hexo-theme-lite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.