Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 1.14 KB

README.zh-CN.md

File metadata and controls

47 lines (33 loc) · 1.14 KB

vite-uni-await-onlaunch

解决uniapp+vue3.2中onlaunch和onload之间异步问题的vite插件

Install (pnpm or npm)

pnpm add vite-uni-await-onlaunch -D

or

npm i vite-uni-await-onlaunch -D

Usage

import { defineConfig, Plugin } from 'vite'
import vue from '@vitejs/plugin-vue'
import AwaitOnlaunch from 'vite-uni-await-onlaunch'

export default defineConfig({
  plugins: [vue(), AwaitOnlaunch({
    fn: () => {
      // your code
      // return a promise
      return Promise.resolve(1)
    }
  })],
})

0ptions

参数 必填 类型 默认值 说明
fn yes () => Promise<any>
当前页面要先执行的方法,如登录等
pagesRE no RegExp src下的pages目录
需要插入fn的页面正则,默认src下的pages目录
triggerMethods no string[] ['onLoad', 'onShow']
插入的生命周期数组,优先级递减,只插入一个,如页面有onLoad和onShow,只在onLoad中提前执行fn

License

MIT