Skip to content

Vue Guide

Vue Router History 模式

router.js

js
import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    //...
  ],
});

vue.config.js

js
  publicPath: '/',

nginx配置

config
location / {
  #history模式配置
  try_files $uri $uri/ /index.html;
  #禁止路由缓存,如果有其他规则,如img,会优先匹配img的配置。所以不影响
  add_header Cache-Control "no-store, no-cache";
  expires      -1;
}

Hbiuder 打包

hbiuder.d.ts

ts
declare namespace plus {
  const key = {
    addEventListener(eventName: string, Funciton): void;,
  };
}

vite.config.ts

ts
defineConfig({
  base: "./", //资源地址
});

router

createWebHashHistory mode

App.vue

ts
//监听返回键
document.addEventListener("plusready", function() {
  plus.key.addEventListener("backbutton", function() {
    router.go(-1);
  });
});