当前位置:网站首页>如何开发引入小程序插件
如何开发引入小程序插件
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"
}
}
}
}边栏推荐
- [Yugong series] go teaching course 003-ide installation and basic use in July 2022
- HDU 4391 Paint The Wall 段树(水
- Create a virtual machine on VMware (system not installed)
- 总结出现2xx、3xx、4xx、5xx状态码的原因
- Analysis and test of ModbusRTU communication protocol
- 华为快游戏调用登录接口失败,返回错误码 -1
- 场景化面试:关于分布式锁的十问十答
- Implementation technology of recovery
- Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
- crm创建基于fetch自己的自定义报告
猜你喜欢

2.2 basic grammar of R language

递归查询多级菜单数据

Type of fault

Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture

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

【愚公系列】2022年7月 Go教学课程 004-Go代码注释

MMAP

ICMP introduction

Alibaba cloud award winning experience: build a highly available system with polardb-x

装饰器学习01
随机推荐
PyGame practical project: write Snake games with 300 lines of code
Gcc9.5 offline installation
总结出现2xx、3xx、4xx、5xx状态码的原因
R language learning notes
AD637使用筆記
DataGrid directly edits and saves "design defects"
Pointer parameter passing vs reference parameter passing vs value parameter passing
AD637使用笔记
Decorator learning 01
Meituan dynamic thread pool practice ideas, open source
Codeforces 12D Ball 树形阵列模拟3排序元素
Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
regular expression
微服務鏈路風險分析
Recovery technology with checkpoints
如何向mongoDB中添加新的字段附代码(全)
About the writing method of SQL field "this includes" and "included in" strings
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
Deeply convinced plan X - network protocol basic DNS
MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器