Skip to content

引入

ts
import { getRouteLeaveCache, startUniProject } from 't-comm';

// 不支持 tree-shaking 的项目
import { getRouteLeaveCache, startUniProject} from 't-comm/lib/uni-app/index';

// 只支持 ESM 的项目
import { getRouteLeaveCache, startUniProject} from 't-comm/es/uni-app/index';

getRouteLeaveCache()

描述

路由离开前记住缓存,返回后不刷新页面

比如创建赛事页面,如果前往查看规则,返回后,希望保留之前的表单

注意,用了这个 mixin,就不要用 onShow 了,而是用 mounted, 否则可能会重复触发刷新

参数

参数名类型描述
config.refreshstring

刷新方法

返回:

返回对象,包含 beforeRouteLeave 和 activated 方法

startUniProject(options)

描述

启动 uni-app 项目

参数

参数名描述
options

参数

示例

ts
startUniProject();

startUniProject({
  debug: false, // 默认为 true,会打印参数
})