当前位置:网站首页>如何開發引入小程序插件
如何開發引入小程序插件
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"
}
}
}
}边栏推荐
- Drawing HSV color wheel with MATLAB
- EBS Oracle 11g 克隆步骤(单节点)
- K210 learning notes (IV) k210 runs multiple models at the same time
- Livelocks and deadlocks of concurrency control
- Blocking protocol for concurrency control
- Serializability of concurrent scheduling
- Blocking of concurrency control
- Net small and medium-sized enterprise project development framework series (one)
- Overview of concurrency control
- Index optimization of performance tuning methodology
猜你喜欢

EBS Oracle 11g cloning steps (single node)

华为快游戏调用登录接口失败,返回错误码 -1

Server optimization of performance tuning methodology

Database tuning solution

Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer

Livelocks and deadlocks of concurrency control

AD637使用筆記

Interprocess communication in the "Chris Richardson microservice series" microservice architecture

资深电感厂家告诉你电感什么情况会有噪音电感噪音是比较常见的一种电感故障情况,如果使用的电感出现了噪音大家也不用着急,只需要准确查找分析出什么何原因,其实还是有具体的方法来解决的。作为一家拥有18年品牌

从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
随机推荐
AD637 usage notes
Cold violence -- another perspective of objective function setting
Huawei cloud modelarts text classification - takeout comments
Interprocess communication in the "Chris Richardson microservice series" microservice architecture
Robot operation mechanism
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
Poj3414 extensive search
Two stage locking protocol for concurrency control
PIP install beatifulsoup4 installation failed
Poj3414广泛搜索
Drawing HSV color wheel with MATLAB
Kingbasees v8r3 cluster maintenance case -- online addition of standby database management node
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
Environment configuration problem record
How to use tensorflow2 for cat and dog classification and recognition
QML reported an error expected token ";", expected a qualified name ID
How to organize an actual attack and defense drill
Storage optimization of performance tuning methodology
华为快游戏调用登录接口失败,返回错误码 -1
Defect detection - Halcon surface scratch detection