bytefun-wxapp
Version:
ByteFun JavaScript SDK
97 lines (80 loc) • 1.9 kB
Markdown
# bytefun-wxapp
> ByteFun快速开发平台,微信小程序端的SDK
登录 [ByteFun官网](https://www.bytefungo.com/) 查看更多信息
## 安装
使用 npm:
```sh
npm install bytefun-wxapp
```
使用 yarn:
```sh
yarn add bytefun-wxapp
```
## 使用
APP_ID 和 APP_KEY 请登录 [ByteFun官网](https://www.bytefungo.com/) 获取。
1. 在 app.js 中初始化 SDK:
```js
import { ByteFunSDK } from 'bytefun-wxapp';
App({
onLaunch() {
ByteFunSDK.init({
app: this,
serverLib: new ByteFunServer(),
appId: AppConfig.APP_ID,
appKey: AppConfig.APP_KEY,
require: function($uri){
try{
return require($uri)
}catch(e){
}
}
})
},
})
```
2. 在page.js中使用 SDK:
```js
import { ByteFunSDK } from 'bytefun-wxapp';
Page({
data: {
compList: [],
dialogCompList: [],
fixCompList: [],
shareAppData: null,
shareTimelineData: null,
},
onLoad(options){
ByteFunSDK.pageLoad(this, options)
},
});
```
3. 在page.json中配置:
```json
{
"usingComponents": {
"bytefun-component": "@bytefun-wxapp/bytefun-component/bytefun-component"
}
}
```
4. 在page.wxml中使用组件:
```html
<block wx:for="{{compList}}" wx:key="index">
<bytefun-component comp="{{ item }}"> </bytefun-component>
</block>
<block wx:for="{{fixCompList}}" wx:key="index">
<bytefun-component comp="{{ item }}"> </bytefun-component>
</block>
<block wx:for="{{dialogCompList}}" wx:key="index">
<bytefun-component comp="{{ item }}"> </bytefun-component>
</block>
```
ByteFunServer 接口实现:
```js
import { IServerLib } from 'bytefun-wxapp';
class ByteFunServer implements IServerLib {
...
}
```
ByteFunServer 接口实现具体逻辑,具体请参考 [ByteFun 官网文档](https://www.bytefungo.com) 对应的DEMO工程
更多信息请访问
[ByteFun 官网](https://www.bytefungo.com)