Socket
Socket
Sign inDemoInstall

kbone-api

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    kbone-api

common api for developing cross-platform app


Version published
Weekly downloads
69
decreased by-48.51%
Maintainers
1
Install size
260 kB
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 23 Mar 2020

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc