Skip to content

Commit

Permalink
Merge pull request #54 from yuezk/patch-1
Browse files Browse the repository at this point in the history
Improve the usage in browser side
  • Loading branch information
JasonBoy committed Sep 24, 2020
2 parents 1729cba + 4c829f4 commit 87fbe68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ const wx = new Wechat(wechatConfig);


## Browser Side Usage

You can use it from the browser side as follows. Since we have [configured the `browser` field in package.json](https://github.com/yuezk/wechat-jssdk/blob/3ab192a5a67e8db65b2ae6cd9978013eef363b73/package.json#L7), the bundlers (e.g., webpack or rollup, etc.) will resolve the module to `wechat-jssdk/dist/client.umd.js`.

```javascript
const WechatJSSDK = require('wechat-jssdk/dist/client.umd');
const WechatJSSDK = require('wechat-jssdk');
//ES6 import
import WechatJSSDK from 'wechat-jssdk/dist/client.umd';
import WechatJSSDK from 'wechat-jssdk';
const wechatObj = new WechatJSSDK(config)

// or if you do not have a bundle process, just add the script tag, and access "WechatJSSDK" from window, e.g:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Next-Generation WeChat JS-SDK integration with NodeJS",
"main": "./lib/index.js",
"source": "./lib/client.js",
"browser": "./dist/client.umd.js",
"engines": {
"node": ">= 8.6"
},
Expand Down

0 comments on commit 87fbe68

Please sign in to comment.