当前位置:网站首页>如何开发引入小程序插件
如何开发引入小程序插件
2022-07-05 22:00:00 【InfoQ】
1、小程序插件引入
2 添加插件
3 引入插件代码包
{
"plugins": {
"myPlugin": {
"version": "1.0.0",
"provider": "插件 id"
}
}
}4在分包内引入插件代码包
{
"subpackages": [
{
"root": "packageA",
"pages": [
"pages/cat",
"pages/dog"
],
"plugins": {
"myPlugin": {
"version": "1.0.0",
"provider": "插件 id"
}
}
}
]
}- 仅能在这个分包内使用该插件;
- 同一个插件不能被多个分包同时引用;
5使用插件
6自定义组件
{
"usingComponents": {
"hello-component": "plugin://myPlugin/hello-component"
}
}- 默认情况下,页面中的 this.selectComponent 接口无法获得插件的自定义组件实例对象;
- ft.createSelectorQuery 等接口的 >>> 选择器无法选入插件内部。
7页面
<navigator url="plugin://myPlugin/hello-page">
Go to pages/hello-page!
</navigator>8 js 接口
var myPluginInterface = requirePlugin('myPlugin');
myPluginInterface.hello();
var myWorld = myPluginInterface.world;var myPluginInterface = requirePlugin('插件 id');9导出到插件
{
"myPlugin": {
"version": "1.0.0",
"provider": "插件 id",
"export": "index.js"
}
}// index.js
module.exports = { whoami: 'MiniProgram' }// plugin
requireMiniProgram().whoami // 'MiniProgram'10为插件提供自定义组件
<!-- miniprogram/page/index.fxml -->
<plugin-view generic:mp-view="comp-from-miniprogram" />{
"myPlugin": {
"provider": "插件 id",
"version": "1.0.0",
"genericsImplementation": {
"plugin-index": {
"mp-view": "components/comp-from-miniprogram"
}
}
}
}边栏推荐
- Reptile practice
- Summary of El and JSTL precautions
- 854. String BFS with similarity K
- 大约SQL现场“这包括”与“包括在”字符串的写法
- 他们主动布局(autolayout)环境的图像编辑器
- Basic grammar of interview (Part 1)
- Code bug correction, char is converted to int high-order symbol extension, resulting in changes in positivity and negativity and values. Int num = (int) (unsigned int) a, which will occur in older com
- DataGrid directly edits and saves "design defects"
- R language learning notes
- CRM creates its own custom report based on fetch
猜你喜欢

Incentive mechanism of Ethereum eth

QML reported an error expected token ";", expected a qualified name ID

Oracle checkpoint queue - Analysis of the principle of instance crash recovery

Shell script, awk uses if, for process control

Meituan dynamic thread pool practice ideas, open source

Bitbucket installation configuration

Oracle检查点队列–实例崩溃恢复原理剖析

深信服X计划-网络协议基础 DNS

1.2 download and installation of the help software rstudio

Daily question brushing record (XIV)
随机推荐
Poj3414广泛搜索
怎么利用Tensorflow2进行猫狗分类识别
PyGame practical project: write Snake games with 300 lines of code
如何组织一场实战攻防演练
CRM creates its own custom report based on fetch
Analyse des risques liés aux liaisons de microservices
Multiplexing of Oracle control files
EBS Oracle 11g cloning steps (single node)
华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
Recovery technology with checkpoints
Robot operation mechanism
SQL knowledge leak detection
大约SQL现场“这包括”与“包括在”字符串的写法
Cold violence -- another perspective of objective function setting
Dbeaver executes multiple insert into error processing at the same time
C language knowledge points link
微服務鏈路風險分析
Huawei fast game failed to call the login interface, and returned error code -1
递归查询多级菜单数据
poj 3237 Tree(树链拆分)