Socket
Book a DemoInstallSign in
Socket

kbone-api

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kbone-api

common api for developing cross-platform app

latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
74
-50.67%
Maintainers
1
Weekly downloads
 
Created
Source

kbone-api

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

特性

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

快速上手

下载 kbone-api

npm install kbone-api

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

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>

LICENSE

MIT

Keywords

kbone-api

FAQs

Package last updated on 23 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts