Socket
Socket
Sign inDemoInstall

uniapp-router-next

Package Overview
Dependencies
0
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.9 to 1.2.0

2

package.json
{
"name": "uniapp-router-next",
"version": "1.1.9",
"version": "1.2.0",
"description": "",

@@ -5,0 +5,0 @@ "exports": {

@@ -9,3 +9,3 @@ # uniapp-router-next

$ npm install uniapp-router-next
$ npm install unplugin-uni-router -D
$ npm install unplugin-uni-router -D
```

@@ -29,3 +29,13 @@

const router = createRouter({
routes,
routes: [
...routes,
// 通配符,一般用于匹配不到路径跳转404页面
{
path: '*',
redirect: () => {
// 可返回{ name: '404' },{ path: '/pages/404/404' }, '/pages/404/404'
return { name: '404' }
}
}
],
//@ts-ignore

@@ -72,2 +82,3 @@ platform: process.env.UNI_PLATFORM,

router.switchTab..
router.navigateBack...
```

@@ -81,2 +92,10 @@

```
#### 组件props
```js
// 跳转类型
navType = 'navigate' | 'redirect' | 'reLaunch' | 'switchTab' | 'navigateBack'
// navType = navigateBack时,可传回退页面层数
delta //默认值为1
```
### 路由信息

@@ -109,2 +128,84 @@ ```typescript

})
```
```
### 实验性功能
#### App.vue 模板替换
- 开启该功能 (unplugin-uni-router需更新到1.2.0版本以上)
```ts
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import uniRouter from 'unplugin-uni-router/vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [uni(),uniRouter({
replaceAppToPages: true //开启模板替换功能
})]
})
```
- 在App.vue中写入公共模板
```html
<template>
<view>header</view>
<outlet />
<view>footer</view>
</template>
<script setup lang="ts">
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
onLaunch(() => {
console.log("App Launch");
});
onShow(() => {
console.log("App Show");
});
onHide(() => {
console.log("App Hide");
});
</script>
<style></style>
```
- 最终会替换所有在pages.json中注册的页面
```html
// page.vue
<template>
<view>page</view>
</template>
```
- 替换结果
```html
// page.vue
<template>
<view>header</view>
<view>page</view>
<view>footer</view>
</template>
```
- 取消某一页面的替换
在pages.json中添加skipReplace
```json
{
"pages": [
{
"path": "pages/index/index",
"name": "index",
"aliasPath": "/",
"meta": {
},
"skipReplace": true
}]
}
```
#### 注意
App.vue 模板替换会影响页面的布局,请谨慎使用,而且替换只能替换template中的静态内容,无法替换template中标签绑定的数据

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc