dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.02k stars 3.63k forks source link

组件内如何使用微信视频插件 #652

Closed bluefox1688 closed 5 years ago

bluefox1688 commented 5 years ago

我已在manifest.json里配置了plugins插件 "mp-weixin" : { "appid" : "wx", "setting" : { "urlCheck" : false, "minified" : true }, "usingComponents" : true, "plugins": { "tencentvideo": { "version": "1.3.6", "provider": "wxa75efa648b60994b" } } },

请问一下,在组件里使用注册此插件? 我测试了 import txvVideo from 'plugin://tencentvideo/video'; 注册方法,但提示未找到。 目前我只需要在微信端使用此插件

Wangyaqi commented 5 years ago

const TxvContext = requirePlugin("tencentvideo");
使用微信小程序插件注意查看插件文档 https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wxa75efa648b60994b&token=618535222&lang=zh_CN

bluefox1688 commented 5 years ago

@Wangyaqi 您好,我试了一下你这个办法。 发现是能注册插件后调用插件的方法 我现在的情况是,在uniapp无法注册插件

Wangyaqi commented 5 years ago

你是用HBuilderX创建的工程还是vue-cli创建的工程,如果是HBuilderX的话告诉我一下版本号

bluefox1688 commented 5 years ago

@Wangyaqi HBuilderX 2.1.3.20190723 HBuilderX创建的工程

Wangyaqi commented 5 years ago

去官网下个alpha版试试

Wangyaqi commented 5 years ago

wx-plugin-test.zip 这个是我写的一个小demo,你可以跑一下看看

bluefox1688 commented 5 years ago

@Wangyaqi 好的,非常感谢

bluefox1688 commented 5 years ago

我试用了你的demo,但发现还是无法注册腾讯视频插件,无法播放

Wangyaqi commented 5 years ago

腾讯视频插件使用比较麻烦,你可以先用一个简单的插件试一下插件的用法,比如腾讯地铁图插件,然后再排查是哪块出了问题

bluefox1688 commented 5 years ago

就是在json文件里,没有这个配置 usingComponents: { 'txv-video': 'plugin://tencentvideo/video', } 才导致了无法插放,我自己在dev里手工注册这个插件,就可以播放。 然后我测试了在vue文件里注册,试了很多办法,在json就是没有这个注册插件

bluefox1688 commented 5 years ago

hbx已经更新到alpha了 manifest.json也都配置的,如果不配置,即使手工注册usingComponents: { 'txv-video': 'plugin://tencentvideo/video', }也无法播放

Wangyaqi commented 5 years ago

了解了,就是组件的json文件没有地方配置是吧

bluefox1688 commented 5 years ago

嗯嗯,是的 我另外尝试在vue文件的注册事件components来注册'txv-video': 'plugin://tencentvideo/video',,但被hbx过滤了,没有同步在json文件里同步生成'txv-video': 'plugin://tencentvideo/video',。 最终导致无法播放。

bluefox1688 commented 5 years ago

目前我们只能在build后,再手工在json文件里配置,超级麻烦

bluefox1688 commented 5 years ago

我说的json是指页面json文件

Wangyaqi commented 5 years ago

页面的可以在pages.json里面配置

bluefox1688 commented 5 years ago

pages.json我也试过,在页面的json文件还是没有同步'txv-video': 'plugin://tencentvideo/video'

Wangyaqi commented 5 years ago

配置在style的mp-weixin下面试试,我现在没在电脑前,只能让你多试试看了

bluefox1688 commented 5 years ago

image 那你看看,这是我在pages.json注册的,是用usingComponents关键词还是其他?

Wangyaqi commented 5 years ago

在style下面配置mp-weixin里面的配置会被单独拷贝到微信小程序里

bluefox1688 commented 5 years ago

我在pages.json注册成功了,但还是有一个问题。 如果我是把txv-video放在组件里的话,即使在pages.json注册成功,组件里也无法播放,因为在pages.json只是注册到了页面,没有注册到组件里 因为项目的架构需求,视频插件只能放在组件里

Wangyaqi commented 5 years ago

那你配置在globalStyle里面,看看组件内能用不

bluefox1688 commented 5 years ago

感谢 感谢,放在globalStyle终于可以了