1.1.0 • Published 3 years ago

hishion-utils v1.1.0

Weekly downloads
7
License
ISC
Repository
-
Last release
3 years ago

uni-app基础函数封装

安装

npm install hishion-utils -S

使用

// main.js
import Vue from 'vue'

import utils from 'hishion-utils'
Vue.use(utils)

route

  • 页面跳转api。传参可以是string的路径,或者路径对象,如{url: 'xxx'}
// $navigate() 对应uni.navigateTo()
this.$navigate('/pages/order/index')
// or
this.$navigate({
  url: '/pages/order/index'
})
// 还有$switch, $redirect, $reLaunch
  • 页面返回。传参是返回层级,默认是1
this.$goBack()

msg

封装uni.showToast()

// 基本方法
this.$msg('hello')

// 配置使用,icon: 'success', 'none'
this.$msg('hello', {icon?, duration?, mask?})

getPage

获取页面实例,一般用于操作某方法等。传参是相对当前页面之前的层级,默认是0,为当前页面

小程序需要获取this.$getPage().$vm

// default 当前页面
this.$getPage()

// 前一页面
this.$getPage(1)

store

缓存管理对象,设置、获取和清除缓存api

// 设置缓存
this.$s.set('key', 'value')
this.$s.set('key1', 'value1')
// 获取缓存
this.$s.get('key')
// 清除缓存,可以传单个key或者key数组
this.$s.clear('key')
this.$s.clear(['key', 'key1'])
1.1.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago