1.0.3 • Published 1 year ago
bytefun-wxapp v1.0.3
bytefun-wxapp
ByteFun快速开发平台,微信小程序端的SDK
登录 ByteFun官网 查看更多信息
安装
使用 npm:
npm install bytefun-wxapp使用 yarn:
yarn add bytefun-wxapp使用
APP_ID 和 APP_KEY 请登录 ByteFun官网 获取。
- 在 app.js 中初始化 SDK:
 
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){
        }
      }
    })
  },
})- 在page.js中使用 SDK:
 
import { ByteFunSDK } from 'bytefun-wxapp';
Page({
  data: {
    compList: [],
    dialogCompList: [],
    fixCompList: [],
    shareAppData: null,
    shareTimelineData: null,
  },
  onLoad(options){
    ByteFunSDK.pageLoad(this, options)
  },
});- 在page.json中配置:
 
{
   "usingComponents": {
      "bytefun-component": "@bytefun-wxapp/bytefun-component/bytefun-component"
   }
}- 在page.wxml中使用组件:
 
<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 接口实现:
import { IServerLib } from 'bytefun-wxapp';
class ByteFunServer implements IServerLib {
    ...
}ByteFunServer 接口实现具体逻辑,具体请参考 ByteFun 官网文档 对应的DEMO工程
更多信息请访问 ByteFun 官网