taro v2.0.3 video标签官方例子报错Cannot read property 'elem' of undefined
问题描述
taro版本是v2.0.3,video视频标签的官方例子进入页面后会报4个Cannot read property 'elem' of undefined错误,但是功能都可以正常使用只是在播放后点击左下角的暂停按钮时同样会报上述错误
复现步骤
通过taro init myApp按流程安装项目 将video标签的官方例子复制到项目中 yarn dev:weapp启动项目 就会出现Cannot read property 'elem' of undefined错误
代码就是框架到官方index代码 里面只替换了video import Taro, { Component } from '@tarojs/taro' import { View, Button, Text } from '@tarojs/components' import { connect } from '@tarojs/redux'
import { add, minus, asyncAdd } from '../../actions/counter'
import './index.less'
@connect(({ counter }) => ({ counter }), (dispatch) => ({ add () { dispatch(add()) }, dec () { dispatch(minus()) }, asyncAdd () { dispatch(asyncAdd()) } })) class Index extends Component {
config = {
navigationBarTitleText: '首页'
}
componentWillReceiveProps (nextProps) { console.log(this.props, nextProps) }
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
render () {
return (
export default Index
CC @Chen-jj
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
把你自己的代码贴出来,另外,在小程序端 Video 组件就是小程序原生组件,如果出现问题,建议先排查是不是自己的环境问题,或者小程序的问题
`import Taro, { Component } from '@tarojs/taro' import { View, Button, Text } from '@tarojs/components' import { connect } from '@tarojs/redux'
import { add, minus, asyncAdd } from '../../actions/counter'
import './index.less'
@connect(({ counter }) => ({ counter }), (dispatch) => ({ add () { dispatch(add()) }, dec () { dispatch(minus()) }, asyncAdd () { dispatch(asyncAdd()) } })) class Index extends Component {
config = { navigationBarTitleText: '首页' }
componentWillReceiveProps (nextProps) { console.log(this.props, nextProps) }
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
render () { return (
) } }
export default Index`
这是代码,这是个测试的例子,没有我自己的代码,就是搭了个架子然后把官方例子复制进去了,然后yarn dev:weapp弹出:版本问题 Taro CLI 与本地安装运行时框架 @tarojs/taro-weapp 版本不一致, 请确保版本一致! 升级到最新CLI:taro update self 升级到最新依赖库:taro update project 输入了上述两个指令就可以正常启动,然后就会报4个Cannot read property 'elem' of undefined错误,点击左下角的暂停也会出这个错误,但从暂停点击到播放是正常到
你不是说使用 video 会报错么,那你把你修改的代码贴出来
<Video
src='http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'
controls={true}
autoplay={false}
poster='http://misc.aotu.io/booxood/mobile-video/cover_900x500.jpg'
initialTime='0'
id='video'
loop={false}
muted={false}
/>
这个video就是官网上到例子,我没有修改过,我只是建了一个测试的架子,粘贴了官方的例子然后按上述方法启动,就报错了。
这个原生也会有问题,不是框架问题
不过我看到的问题是taro组件内使用video的话createVideoContext的对象无法play,
在页面上的video组件就行
我也遇到了这个问题
那这个问题有什么解决办法么 麻烦问下
不过我看到的问题是taro组件内使用video的话createVideoContext的对象无法play,
这个直接放页面上就行,暂时就这么解决的
Cannot read property 'elem' of undefined
这个不会影响到正常使用,是微信他们基础库的问题 https://developers.weixin.qq.com/community/develop/doc/000caa955b8af8a5f5d986c6456c00?highLine=Cannot%2520read%2520property%2520%27elem%27%2520of%2520undefined
ok 多谢您