Git Product home page Git Product logo

ls_jsbridge's Introduction

JSBridge

H5和客户端之间使用到的桥接封装

Basic Usage

npm install ls-jsbridge -S
or
yarn add ls-jsbridge
import JSBridge from 'ls-jsbridge';

或者

<script src="./dist/JSBridge.js"></script>

页面加载时调用

JSBridge.init({
  debug: false,
  onready: function () {
    JSBridge.getUid({}, function (res) {
      // 处理res
    });
  }
});

init

参数 解释 默认
debug 打开时可看到更多调试信息 false
onready init成功后的回调 null

普通调用

JSBridge.getUid({}, function (res) {
  // 处理res
});

方法

方法名 解释 返回值类型 备注
getUid 获取当前用户uid Number 封装前的类型是不一样的,做了特殊处理,单独使用时需要注意
getToken 获取token String 原生定义的方法名不一样,安卓叫getUserToken
openWeChat 打开微信客户端 undefined ios无返回值
follow 关注/取消关注 undefined ios无返回值,接受两个参数,点击查看
getParams 获取公共参数 string ios无返回值,私信发的链接能正常返回,安卓返回空string
closeWebPage 关闭当前webview undefined ios无返回值,都没有效果
share 分享 undefined ios无返回值,接受参数,点击查看
hasVip 是否是特权版本 string 值为'{ "has_vip": 1 }'

follow

参数 是否必须 解释 类型 备注
hasFollow 是否已经关注 Boolean false为关注,true为取消关注
uid 用户id Number

share

参数 是否必须 解释 类型 备注
shareType 类型 Number QQ-0 微信-1 微博-2 QQ空间-3 朋友圈-4
title 标题 String
content 描述 String
imgUrl 图标 String
url 分享地址 String

关于文件的一些说明

index.js是作为依赖的入口

src/index.js作为编译成dist文件夹下面文件的入口

lib/index.js是主要的逻辑文件

ls_jsbridge's People

Watchers

James Cloos avatar  avatar  avatar

Forkers

asd12l onion2014

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.