当前位置:网站首页>如何開發引入小程序插件
如何開發引入小程序插件
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"
}
}
}
}
边栏推荐
- NET中小型企业项目开发框架系列(一个)
- [Yugong series] go teaching course 003-ide installation and basic use in July 2022
- Summary of data analysis steps
- Meituan dynamic thread pool practice ideas, open source
- 854. String BFS with similarity K
- HDU 4391 Paint The Wall 段树(水
- Two stage locking protocol for concurrency control
- An exception occurred in Huawei game multimedia calling the room switching method internal system error Reason:90000017
- The solution to the problem that Oracle hugepages are not used, causing the server to be too laggy
- Four components of logger
猜你喜欢
Database tuning solution
database mirroring
Recovery technology with checkpoints
Drawing HSV color wheel with MATLAB
An exception occurred in Huawei game multimedia calling the room switching method internal system error Reason:90000017
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
Emotional analysis of wechat chat records on Valentine's day based on Text Mining
Serializability of concurrent scheduling
Exercise 1 simple training of R language drawing
Livelocks and deadlocks of concurrency control
随机推荐
Efficiency difference between row first and column first traversal of mat data types in opencv
MMAP学习
Some common processing problems of structural equation model Amos software
regular expression
Huawei fast game failed to call the login interface, and returned error code -1
Official clarification statement of Jihu company
poj 3237 Tree(樹鏈拆分)
HYSBZ 2243 染色 (树链拆分)
ICMP introduction
资深电感厂家告诉你电感什么情况会有噪音电感噪音是比较常见的一种电感故障情况,如果使用的电感出现了噪音大家也不用着急,只需要准确查找分析出什么何原因,其实还是有具体的方法来解决的。作为一家拥有18年品牌
Overview of concurrency control
Livelocks and deadlocks of concurrency control
微服務鏈路風險分析
EL与JSTL注意事项汇总
Environment configuration problem record
Recovery technology with checkpoints
Drawing HSV color wheel with MATLAB
The American Championship is about to start. Are you ready?
Hysbz 2243 staining (tree chain splitting)
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer