All Projects → wechat-miniprogram → kbone-api

wechat-miniprogram / kbone-api

Licence: MIT license
No description, website, or topics provided.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

kbone-api

kbone-api是一个能同时支持 小程序和 web 开发的多端 api 库。

特性

  • 针对基于 kbone 的多端开发,满足在 Web 上直接使用小程序相关 api
  • 不依赖 kbone 和 kbone-ui,一个无依赖的小程序 api 的跨端库
  • 完整对齐 wx[apis]
  • 同时支持 promise 化和 callback 调用

快速上手

下载 kbone-api

npm install kbone-api

通过模块的方式直接导出模块并使用:

import kboneAPI from 'kbone-api'

kboneAPI.request()
kboneAPI.showToast()
kboneAPI.showModal()

为了方便 Vue 开发,可以直接使用 Vue.use(kboneAPI) 来设置全局对象.

# main.js
import Vue from 'vue'

Vue.use(kboneAPI)

# logic code
<script>
export default {
    name: "LoginComponents",
    methods: {
        gotologin() {
            return this.$api.login().then(() => {
                this.$api.showToast({
                    title: "登录成功",
                })
            })
        },
        getSetting() {
            // 获取用户设置
            return this.$api.getSetting()
                .then(res => {
                    this.$api.showToast({
                        title: res.nickName || "零度的田"
                    })
                })
        }
    }
}
</script>

文档

所有 api 使用对齐小程序 api,具体内容可以参考 小程序 api

线上体验地址为:api/ui/

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].