如何解决集成Parse-SDK-JS以响应应用程序
我尝试用Google搜索一些指南或教程,但没有找到任何指南。有什么方法可以将与Android和iOS方式相同的Parse SDK集成到我的本地应用程序中?因为我尝试集成Parse-SDK-JS,但现在我的应用无法正常工作,因此崩溃,并显示错误Error: Unable to resolve module crypto from node_modules\parse\node_modules\crypto-js\core.js: crypto Could not be found within the project.'
我的代码:
parse.ts:
// In a React Native application
import Parse,{ Error } from 'parse';
// On React Native >= 0.50 and Parse >= 1.11.0,set the Async
import { AsyncStorage } from 'react-native';
export const initParse = () => {
Parse.setAsyncStorage(AsyncStorage);
Parse.initialize('xxxxxxxxxxxxxxxxxxxxxxxxxxx'); //APP_ID
Parse.serverURL = 'https://xxx.herokuapp.com/parse'; //HEROKU URI SERVER
};
export const testCreate = () => {
const Gamescore = Parse.Object.extend('Gamescore');
const gamescore = new Gamescore();
gamescore.set('score',1337);
gamescore.set('playerName','Sean Plott');
gamescore.set('cheatMode',false);
gamescore.save().then(
(gamescore: any) => {
// Execute any logic that should take place after the object is saved.
alert('New object created with objectId: ' + gamescore.id);
},(error: Error) => {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
alert('Failed to create new object,with error code: ' + error.message);
},);
};
index.js:
/**
* @format
*/
import {
AppRegistry
} from 'react-native';
import {
initParse
} from './src/library/parse/parse';
import App from './App';
import {
name as appName
} from './app.json';
initParse();
AppRegistry.registerComponent(appName,() => App);
解决方法
您需要从parse/react-native.js
导入Parse。应该是这样的:
import Parse,{ Error } from 'parse/react-native.js';
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。