react vr中文網(wǎng):www.vr-react.com
react vr的導(dǎo)航一直很少有人去做,場景的切換一般都采用簡單的state管理,也就是點擊vrbutton改變state的值琐鲁,切換新的場景叹俏,同時我們也可以用react上的路由來進(jìn)行路由的導(dǎo)航绽快,此處介紹react-router在react-vr中的應(yīng)用碱屁。
react-router在react-vr中的應(yīng)用:https://github.com/LiuC520/react-vr-router
直接在項目中安裝react-router,
npm install --save react-router
然后在你的文件中引用:
import { MemoryRouter as Router, Redirect, Route, Switch } from 'react-router';
然后:
import React,{Component} from 'react';
import {
AppRegistry,
asset,
Pano,
Text,
View,
} from 'react-vr';
import { MemoryRouter as Router, Redirect, Route, Switch } from 'react-router';
import TS1 from './src/test'
import TS2 from './src/test_1'
class Example extends Component{
render(){
return(
<Router>
<View>
<Route exact path='/' component={TS1}/>
<Route exact path='/test_1' component={TS2}/>
<Route exact path='/test' component={TS1}/>
</View>
</Router>
)
}
}
AppRegistry.registerComponent('Example', () => Example);