s-uni-router
v1.0.9
Published
一个uni-app 路由管理解决方案
Downloads
551
Maintainers
Readme
uniApp router 解决方案
- 首屏首次拦截。
- 路由全局拦截。
useRouter Api 说明链接
界面生命周期请使用 s-uni-router 导出主要用于首次拦截链接
import { onLoad, onShow, onMounted } from "s-uni-router";
具体使用查看 playground 示例
import { RouterGuards } from "s-uni-router";
const guards = new RouterGuards();
export default function () {
guards.beforeEach((form, to) => {
console.log(form, to);
return new Promise((r, s) => {
setTimeout(() => {
r(true);
//测试
}, 5000);
});
});
}
vite.config.js;
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import uniRouterLayout from "@s-router-uni/layout";
export default defineConfig({
plugins: [uniRouterLayout(), uni()],
});
App.vue
<script setup lang="ts">
import { onRouterReady } from "s-uni-router";
onRouterReady("/pages/index/index");
</script>