当前位置:网站首页>如何开发引入小程序插件
如何开发引入小程序插件
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"
}
}
}
}
边栏推荐
- MMAP
- Index optimization of performance tuning methodology
- QML reported an error expected token ";", expected a qualified name ID
- Ad637 notes d'utilisation
- C language knowledge points link
- ICMP 介绍
- Database tuning solution
- Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
- Li Kou ----- the maximum profit of operating Ferris wheel
- About the writing method of SQL field "this includes" and "included in" strings
猜你喜欢
Implementation technology of recovery
EBS Oracle 11g 克隆步骤(单节点)
K210学习笔记(四) K210同时运行多个模型
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
Analysis and test of ModbusRTU communication protocol
华为云ModelArts文本分类–外卖评论
Experienced inductance manufacturers tell you what makes the inductance noisy. Inductance noise is a common inductance fault. If the used inductance makes noise, you don't have to worry. You just need
Incentive mechanism of Ethereum eth
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
Yolov5 training custom data set (pycharm ultra detailed version)
随机推荐
Some common processing problems of structural equation model Amos software
DataGrid directly edits and saves "design defects"
Robot framework setting variables
Evolution of large website architecture and knowledge system
PIP install beatifulsoup4 installation failed
Xlrd common operations
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
How to add new fields to mongodb with code (all)
QML reported an error expected token ";", expected a qualified name ID
Huawei fast game failed to call the login interface, and returned error code -1
crm创建基于fetch自己的自定义报告
Oracle HugePages没有被使用导致服务器很卡的解决方法
多家呼吸机巨头产品近期被一级召回 呼吸机市场仍在增量竞争
Net small and medium-sized enterprise project development framework series (one)
Tips for using SecureCRT
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
EBS Oracle 11g 克隆步骤(单节点)
Ad637 notes d'utilisation
HDU 4391 Paint The Wall 段树(水
Interprocess communication in the "Chris Richardson microservice series" microservice architecture