@ant-credit/bean-sdk
bean 组件 sdk
安装依赖
npm i @ant-credit/bean-sdk --save
代码中使用
添加组件挂在节点
<body>
<div id="BusinessInfo_PC"></div>
</body>
初始化 bean-sdk 并调用组件
import BeanSdk from '@ant-credit/bean-sdk';
import { getMockComponentToken } from './your-own-utils';
async function main() {
const componentToken = await getMockComponentToken();
if (!componentToken) {
return;
}
const beanSdk = new BeanSdk();
await beanSdk.initApiPassthrough();
await beanSdk.init({
componentToken,
});
const BusinessInfo_PC_Component = await beanSdk.create({
name: 'BusinessInfo_PC',
props: {
crn: 'xxxxxxxx',
useInnerDataSource: true,
},
style: `
body {
width: 900px !important;
}
`,
});
BusinessInfo_PC_Component.render('#BusinessInfo_PC');
}
main();
SDK API
BeanSdk 类
BeanSdk.initBeanSdk(param)
- param
- getComponentToken
- BeanSdk
- onComponentTokenExpired
- debug
BeanSdk.renderBeanComponent(param)
- param
- name
- props
- style
- container
- onRequestTooOften
- globalEnv
beanSdk 实例
beanSdk.init(param)
beanSdk.create(param)
beanSdk.render(container)