Reactjs 未捕获错误:TypeError:undefined不是对象(计算';P.Constants';)

Reactjs 未捕获错误:TypeError:undefined不是对象(计算';P.Constants';),reactjs,typescript,react-native,Reactjs,Typescript,React Native,大家好,我是一名新开发人员(很抱歉我的英语不好),我正在学习React native,我还按照教程在这里制作音乐播放器应用程序: 我的问题是,我有一个无法解决的大错误,我在互联网上进行了研究,还从教程的创建者那里选择了GIT,但错误仍然存在 下面是我的app.js: import React, { Component } from 'react'; import Player from './Player'; export const TRACKS = [ { tit

大家好,我是一名新开发人员(很抱歉我的英语不好),我正在学习React native,我还按照教程在这里制作音乐播放器应用程序:

我的问题是,我有一个无法解决的大错误,我在互联网上进行了研究,还从教程的创建者那里选择了GIT,但错误仍然存在

下面是我的app.js:

import React, { Component } from 'react';
import Player from './Player';

export const TRACKS = [
    {
        title: 'Stressed Out',
        artist: 'Twenty One Pilots',
        albumArtUrl: "http://36.media.tumblr.com/14e9a12cd4dca7a3c3c4fe178b607d27/tumblr_nlott6SmIh1ta3rfmo1_1280.jpg",
        audioUrl: "http://dl.fazmusics.in/Ali/music/aban/hot%20100%20.7%20nov%202015(128)/Twenty%20One%20Pilots%20-%20Stressed%20Out.mp3",
    },
    {
        title: 'Love Yourself',
        artist: 'Justin Bieber',
        albumArtUrl: "http://arrestedmotion.com/wp-content/uploads/2015/10/JB_Purpose-digital-deluxe-album-cover_lr.jpg",
        audioUrl: 'http://srv2.dnupload.com/Music/Album/Justin%20Bieber%20-%20Purpose%20(Deluxe%20Version)%20(320)/Justin%20Bieber%20-%20Purpose%20(Deluxe%20Version)%20128/05%20Love%20Yourself.mp3',
    },
    {
        title: 'Hotline Bling',
        artist: 'Drake',
        albumArtUrl: 'https://upload.wikimedia.org/wikipedia/commons/c/c9/Drake_-_Hotline_Bling.png',
        audioUrl: 'http://dl2.shirazsong.org/dl/music/94-10/CD%201%20-%20Best%20of%202015%20-%20Top%20Downloads/03.%20Drake%20-%20Hotline%20Bling%20.mp3',
    },
];

export default class App extends Component {
    render() {
        return <Player tracks={TRACKS} />
    }
}
import React,{Component}来自'React';
从“./Player”导入播放器;
导出常量轨迹=[
{
标题:“压力过大”,
艺术家:《二十一名飞行员》,
albumArtUrl:“http://36.media.tumblr.com/14e9a12cd4dca7a3c3c4fe178b607d27/tumblr_nlott6SmIh1ta3rfmo1_1280.jpg",
音频URL:“http://dl.fazmusics.in/Ali/music/aban/hot%20100%20.7%20nov%202015(128)/20%201%20Pilots%20-%20Stressed%20Out.mp3“,
},
{
标题:“爱你自己”,
艺术家:“贾斯汀·比伯”,
albumArtUrl:“http://arrestedmotion.com/wp-content/uploads/2015/10/JB_Purpose-digital-deluxe-album-cover_lr.jpg",
音频URL:'http://srv2.dnupload.com/Music/Album/Justin%20Bieber%20-%20Purpose%20(豪华%20版本)%20(320)/Justin%20Bieber%20-%20Purpose%20(豪华%20版本)%20128/05%20Love%20Yourself.mp3',
},
{
标题:"热线电话",,
艺术家:“德雷克”,
albumArtUrl:'https://upload.wikimedia.org/wikipedia/commons/c/c9/Drake_-_Hotline_Bling.png',
音频URL:'http://dl2.shirazsong.org/dl/music/94-10/CD%201%20-%20最佳%20%202015%20-%20热门%20下载/03.%20Drake%20-%20热线%20Bling%20.mp3',
},
];
导出默认类应用程序扩展组件{
render(){
返回
}
}
这是我的Player.js,通常我的问题是:

import React, { Component } from 'react';
import {
    View,
    Text,
    StatusBar,
} from 'react-native';
import Header from './Header';
import AlbumArt from './AlbumArt';
import TrackDetails from './TrackDetails';
import SeekBar from './SeekBar';
import Controls from './Controls';
import Video from 'react-native-video';

export default class Player extends Component {
    constructor(props) {
        super(props);

        this.state = {
            paused: true,
            totalLength: 1,
            currentPosition: 0,
            selectedTrack: 0,
            repeatOn: false,
            shuffleOn: false,
        };
    }

    setDuration(data) {
        // console.log(totalLength);
        this.setState({totalLength: Math.floor(data.duration)});
    }

    setTime(data) {
        //console.log(data);
        this.setState({currentPosition: Math.floor(data.currentTime)});
    }

    seek(time) {
        time = Math.round(time);
        this.refs.audioElement && this.refs.audioElement.seek(time);
        this.setState({
            currentPosition: time,
            paused: false,
        });
    }

    onBack() {
        if (this.state.currentPosition < 10 && this.state.selectedTrack > 0) {
            this.refs.audioElement && this.refs.audioElement.seek(0);
            this.setState({ isChanging: true });
            setTimeout(() => this.setState({
                currentPosition: 0,
                paused: false,
                totalLength: 1,
                isChanging: false,
                selectedTrack: this.state.selectedTrack - 1,
            }), 0);
        } else {
            this.refs.audioElement.seek(0);
            this.setState({
                currentPosition: 0,
            });
        }
    }

    onForward() {
        if (this.state.selectedTrack < this.props.tracks.length - 1) {
            this.refs.audioElement && this.refs.audioElement.seek(0);
            this.setState({ isChanging: true });
            setTimeout(() => this.setState({
                currentPosition: 0,
                totalLength: 1,
                paused: false,
                isChanging: false,
                selectedTrack: this.state.selectedTrack + 1,
            }), 0);
        }
    }



    render() {
        const track = this.props.tracks[this.state.selectedTrack];
        const video = this.state.isChanging ? null : (
            <Video source={{uri: track.audioUrl}} // Can be a URL or a local file.
                   ref="audioElement"
                   paused={this.state.paused}               // Pauses playback entirely.
                   resizeMode="cover"           // Fill the whole screen at aspect ratio.
                   repeat={true}                // Repeat forever.
                   onLoadStart={this.loadStart} // Callback when video starts to load
                   onLoad={this.setDuration.bind(this)}    // Callback when video loads
                   onProgress={this.setTime.bind(this)}    // Callback every ~250ms with currentTime
                   onEnd={this.onEnd}           // Callback when playback finishes
                   onError={this.videoError}    // Callback when video cannot be loaded
                   style={styles.audioElement} />
        );

        return (
            <View style={styles.container}>
                <StatusBar hidden={true} />
                <Header message="Playing From Charts" />
                <AlbumArt url={track.albumArtUrl} />
                <TrackDetails title={track.title} artist={track.artist} />
                <SeekBar
                    onSeek={this.seek.bind(this)}
                    trackLength={this.state.totalLength}
                    onSlidingStart={() => this.setState({paused: true})}
                    currentPosition={this.state.currentPosition} />
                <Controls
                    onPressRepeat={() => this.setState({repeatOn : !this.state.repeatOn})}
                    repeatOn={this.state.repeatOn}
                    shuffleOn={this.state.shuffleOn}
                    forwardDisabled={this.state.selectedTrack === this.props.tracks.length - 1}
                    onPressShuffle={() => this.setState({shuffleOn: !this.state.shuffleOn})}
                    onPressPlay={() => this.setState({paused: false})}
                    onPressPause={() => this.setState({paused: true})}
                    onBack={this.onBack.bind(this)}
                    onForward={this.onForward.bind(this)}
                    paused={this.state.paused}/>
                {video}
            </View>
        );
    }
}

const styles = {
    container: {
        flex: 1,
        backgroundColor: 'rgb(255,255,255)',
    },
    audioElement: {
        height: 0,
        width: 0,
    }
};
import React,{Component}来自'React';
进口{
看法
文本,
状态栏,
}从“反应本机”;
从“./头”导入头;
从“/AlbumArt”导入AlbumArt;
从“/TrackDetails”导入TrackDetails;
从“/SeekBar”导入SeekBar;
从“./Controls”导入控件;
从“react native Video”导入视频;
导出默认类播放器扩展组件{
建造师(道具){
超级(道具);
此.state={
是的,
总长度:1,
当前位置:0,
已选择跟踪:0,
重复:错,
shuffleOn:错,
};
}
设置持续时间(数据){
//控制台日志(总长度);
this.setState({totalLength:Math.floor(data.duration)});
}
设定时间(数据){
//控制台日志(数据);
this.setState({currentPosition:Math.floor(data.currentTime)});
}
寻找(时间){
时间=数学。四舍五入(时间);
this.refs.audioElement&&this.refs.audioElement.seek(时间);
这是我的国家({
当前位置:时间,
暂停:错,
});
}
onBack(){
if(this.state.currentPosition<10&&this.state.selectedTrack>0){
this.refs.audioElement&&this.refs.audioElement.seek(0);
this.setState({isChanging:true});
setTimeout(()=>this.setState({
当前位置:0,
暂停:错,
总长度:1,
Ischange:错,
selectedTrack:this.state.selectedTrack-1,
}), 0);
}否则{
this.refs.audioElement.seek(0);
这是我的国家({
当前位置:0,
});
}
}
onForward(){
if(this.state.selectedTrackthis.setState({
当前位置:0,
总长度:1,
暂停:错,
Ischange:错,
selectedTrack:this.state.selectedTrack+1,
}), 0);
}
}
render(){
const track=this.props.tracks[this.state.selectedTrack];
const video=this.state.isChanging?空:(
);
返回(

我不知道是否有办法找到错误的正确位置?因为在屏幕截图上他们说错误位于n,在RCTVIEw中,…我无法理解这一点

谢谢。

你看过吗?那可能有关系。你看过吗?那可能有关系。