当前位置:网站首页>如何開發引入小程序插件
如何開發引入小程序插件
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"
}
}
}
}边栏推荐
- How to organize an actual attack and defense drill
- Poj3414广泛搜索
- DBeaver同时执行多条insert into报错处理
- A long's perception
- Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
- Official clarification statement of Jihu company
- PIP install beatifulsoup4 installation failed
- Shell script, awk condition judgment and logic comparison &||
- Recovery technology with checkpoints
- 2.2.3 output of documents
猜你喜欢

The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!

How to use tensorflow2 for cat and dog classification and recognition

Official clarification statement of Jihu company

MMAP学习

Installation of VMware Workstation

A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition

Deeply convinced plan X - network protocol basic DNS

Drawing HSV color wheel with MATLAB

The real situation of programmers

Storage optimization of performance tuning methodology
随机推荐
regular expression
HDU 4391 Paint The Wall 段树(水
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
Yolov5 training custom data set (pycharm ultra detailed version)
Dbeaver executes multiple insert into error processing at the same time
2.2 basic grammar of R language
场景化面试:关于分布式锁的十问十答
matlab绘制hsv色轮图
Evolution of large website architecture and knowledge system
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
Two stage locking protocol for concurrency control
Exercise 1 simple training of R language drawing
Reptile practice
Interprocess communication in the "Chris Richardson microservice series" microservice architecture
kingbaseES V8R3数据安全案例之---审计记录清除案例
The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
How to organize an actual attack and defense drill
微服務鏈路風險分析
华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010