0
A
回答
0
必須有語法錯誤,你可能會定義一個名爲「名稱」兩次屬性。嘗試檢查它。
0
這是index.android.js
/* @flow */
/**
* Android index
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
} = React;
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
var MobileApp = require('./components/Index');
AppRegistry.registerComponent('MobileApp',() => MobileApp);
這是index.js看起來怎麼樣
/* @flow */
/**
* Index with route mapper
*/
'use strict';
var React = require('react-native');
var {
View,
AppRegistry,
Navigator,
AsyncStorage,
} = React;
var settings = require('../config/settings'),
apiErrors = require('../stores/ApiErrors.json'),
Util = require('../utils/Util');
//Components
var Accounts = require('./Accounts'),
ActivityDashboard = require('./ActivityDashboard'),
Advice = require('./Advice'),
Dashboard = require('./Dashboard'),
History = require('./History'),
HealthQuiz = require('./HealthQuiz'),
HealthQuizCover = require('./HealthQuizCover'),
HealthQuizResult = require('./HealthQuizResult'),
HumanAPIConnect = require('./HumanAPIConnect'),
HumanConnectCordovaTest = require('./HumanConnectCordovaTest'),
LogIn = require('./LogIn'),
ManualAdd = require('./ManualAdd'),
MedicalInfo = require('./MedicalInfo'),
Overview = require('./Overview'),
Records = require('./Records'),
SignUp = require('./SignUp'),
WelcomeScenes = require('./WelcomeScenes');
if (settings.mode === 'dev') {
}
var RouteMapper = function(route, navigator) {
//Log route name
console.log('Route: ' + route.name);
if (route.name === 'Accounts') {
return (
<Accounts navigator={navigator} />
);
}
else if (route.name === 'ActivityDashboard') {
return (
<ActivityDashboard navigator={navigator} />
);
} else if (route.name === 'Advice') {
return (
<Advice navigator={navigator}
component={route.component}
/>
)
} else if (route.name === 'Dashboard') {
return (
<Dashboard navigator={navigator}
component={route.component}
/>
)
} else if (route.name === 'HealthQuiz') {
return (
<HealthQuiz navigator={navigator} />
);
} else if (route.name === 'HealthQuizCover') {
return (
<HealthQuizCover navigator={navigator} />
);
} else if (route.name === 'HealthQuizResult') {
return (
<HealthQuizResult navigator={navigator}
result={route.result}
/>
);
} else if (route.name === 'History') {
return (
<History navigator={navigator}
component={route.component}
metric={route.metric}
/>
)
} else if (route.name === 'HumanAPIConnect') {
return (
<HumanAPIConnect navigator={navigator} />
);
} else if (route.name === 'HumanConnectCordovaTest') {
return (
<HumanConnectCordovaTest navigator={navigator} />
);
} else if(route.name === 'LogIn') {
return (
<LogIn navigator={navigator} />
);
} else if (route.name === 'LogOut') {
AsyncStorage.multiRemove(['email', 'username', 'auth', 'gender', 'age']);
console.log('Route: LogIn');
return (
<LogIn navigator={navigator} />
);
} else if(route.name === 'ManualAdd') {
return (
<ManualAdd navigator={navigator} />
);
} else if (route.name === 'MedicalInfo') {
return (
<MedicalInfo navigator={navigator} />
);
} else if (route.name === 'Overview') {
return (
<Overview navigator={navigator}
mainSelection={true}
/>
);
} else if (route.name === 'Records') {
return (
<Records navigator={navigator}
component={route.component}
collection={route.collection}
/>
);
} else if (route.name === 'SignUp') {
return (
<SignUp navigator={navigator} />
);
} else if (route.name === 'WelcomeScenes') {
return (
<WelcomeScenes navigator={navigator}/>
);
}
};
var Index = React.createClass({
getInitialState: function() {
return {};
},
componentWillMount: function() {
AsyncStorage.multiGet(['username', 'auth', 'gender', 'age']).then((values) => {
var username = values[0][1],
auth = values[1][1],
gender = values[2][1],
age = values[3][1],
urlPattern = '/auth/confirm-auth/';
if (!(username && auth && gender && age)) {
console.log('No username and/or auth were found');
this.setState({initialRoute: 'LogIn'});
} else {
this.setState({'username': username, 'auth': auth});
Util.fetchAPIData(null, username, auth, urlPattern, null, this._handleAPIResponse,
this._onMissingConnection, this._handleFetchError, false);
}
}).done();
},
_onMissingConnection: function() {
this.setState({initialRoute: 'LogIn'});
},
_handleFetchError: function(error) {
console.log(error);
this.setState({initialRoute: 'LogIn'});
},
_handleAPIResponse: function(responseData) {
//Set initial route depending on whether or not credentials are valid
var initialRoute = (responseData.error == apiErrors.noError) ? 'Overview' : 'LogIn';
this.setState({initialRoute: initialRoute});
},
render: function() {
//For debugging purposes
if (settings.mode === 'dev') {
return (
<Navigator
initialRoute={{
name: 'Accounts'
}}
renderScene={RouteMapper}
/>
);
}
if (!('initialRoute' in this.state)) {
return <View/>;
}
return (
<Navigator
initialRoute={{
name: this.state.initialRoute
}}
renderScene={RouteMapper}
/>
);
},
});
module.exports = Index;
+0
嘗試刪除if(settings.mode ==='dev')塊並運行它。名爲'name'的屬性的重定義可能發生在render()上。 –
+0
嗨弗蘭茲,感謝您的幫助,但沒有工作:(有什麼我可以嘗試嗎? –
相關問題
- 1. 陣營母語:錯誤而導入
- 2. 陣營母語:等待是
- 3. 列表視圖數據源錯誤 - 陣營母語
- 4. 陣營母語:Flex的行爲不同
- 5. 陣營終極版...語法錯誤
- 6. 陣營母語:以下步驟
- 7. 陣營母語:模塊化造型
- 8. 陣營母語:訪問JSON數據
- 9. 陣營母語:process.env只有NODE_ENV
- 10. 陣營與反應母語-FCM
- 11. 錯誤與CONCAT陣營
- 12. 陣營倒計時錯誤
- 13. 陣營機調試錯誤
- 14. 陣營本地_weakMap2錯誤
- 15. NavigatorIOS錯誤 - 陣營本地
- 16. 錯誤安裝陣營
- 17. 陣營類型錯誤
- 18. 陣營出口報關聲明預計
- 19. 陣營機錯誤:錯誤:看EMFILE
- 20. 的港口
- 21. 陣營從出口
- 22. 陣營母語:關閉抽屜在場景漫遊使用陣營本地路由器流量
- 23. 陣營,Redux的錯誤時的WebPack:語法錯誤:意外的令牌
- 24. 陣營的WebPack使我新的錯誤
- 25. 陣營Android原生語法錯誤:試圖重新定義屬性「關鍵」
- 26. MySQL版本相關的語法錯誤
- 27. 陣營母語:Access組件狀態的靜態函數
- 28. 陣營母語:Facebook的API/ME /圖片調用返回FACEBOOK_NON_JSON_RESULT
- 29. (陣營母語)加載本地HTML文件到的WebView
- 30. 陣營母語:RNGeocoder.reverseGeocodeLocation - 可能未處理的承諾拒絕
我是新來的反應原生的編程,而不是sur e哪個文件/哪裏檢查,因爲錯誤並不真正指向文件。 –
如果你能向我展示一些代碼或你的index.android.js代碼,我會幫助你更好。 –
再次感謝,包含下面的代碼。 –