配置微信小程序插件
注意事項
- 正式開始使用微信小程序插件之前需先在微信公衆平臺 -> 設置->第三方設置 -> 插件管理處添加插件
- 要保證項目內微信小程序appid和申請插件的微信小程序appid一致插件纔可使用
引入插件代碼包
使用插件之前開發者需要在manifest.json中的mp-weixin內聲明使用的插件,具體配置參照所用插件的開發文檔
/* 小程序特有相關 */
"mp-weixin" : {
"appid" : "xxxx",
"setting" : {
"urlCheck" : false,
"postcss" : true
},
"usingComponents" : true,
"plugins": {
"tencentvideo": {
"version": "1.2.4",
"provider": "wxa75efa648b60994b"
}
}
},
在頁面中使用小程序插件
在 pages.json 對應頁面的 style -> usingComponents 引入組件:
{
"pages": [
{
"path": "index/index",
"style": {
"usingComponents": {
// #ifdef MP-WEIXIN
"txv-video": "plugin://tencentvideo/video"
// #endif
}
}
}
]
}
在頁面不需要其他配置,直接使用就可以
<template>
<view class="">
<txv-video vid="e0354z3cqjp" playerid="txv1"></txv-video>
</view>
</template>
檢查結果
配置好了,檢查下是否有效吧,運行後可以看到通過vid就可以播放騰訊視頻
參考文檔:
騰訊視頻插件文檔:
https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wxa75efa648b60994b
Dcloud官方文檔
https://uniapp.dcloud.io/component/mp-weixin-plugin
https://uniapp.dcloud.io/frame
注:貌似這個插件只能在小程序用