my react-native version:0.24.0
index.ios.js:
<!DOCTYPE html>
<head>
<title>Pintrest Login</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<p onclick="pintrest()">Click me</p>
<div id="result"></div>
</body>
<script>
function pintrest(){
window.pAsyncInit = function() {
PDK.init({
appId: "You api key",
cookie: true
});
//login
PDK.login({ scope : 'read_relationships,read_public' }, function(response){
if (!response || response.error) {
// alert('Error occurred');
} else {
//console.log(JSON.stringify(response));
}
//get board info
var pins = [];
PDK.request('/v1/me/', function (response) {
if (!response || response.error) {
//alert('Error occurred');
} else {
console.log(JSON.stringify(response));
// alert('success');
console.log(PDK.getSession().accessToken);
var yahoo = $( "#result" ).load( "https://api.pinterest.com/v1/me/?access_token="+PDK.getSession().accessToken+"&fields=counts" );
console.log(yahoo);
PDK.logout();
}
});
//end get board info
});
//end login
};
(function(d, s, id){
var js, pjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//assets.pinterest.com/sdk/sdk.js";
pjs.parentNode.insertBefore(js, pjs);
}(document, 'script', 'pinterest-jssdk'));
}
</script>
</body>
</html>
entry.js:
require('./entry');
答案 0 :(得分:0)
<强> index.ios.js 强>
'use strict';
require('./entry');
<强> entry.js:强>
import React,
{AppRegistry, StyleSheet, Text, View } from 'react-native';
class movieView extends React.Component
{
}
AppRegistry.registerComponent('movieView', () => movieView);
您的问题不明确,也许您得到的错误是因为您为文件路径提供的命名空间。 希望它会有所帮助!
答案 1 :(得分:0)
假设您的项目路径,我猜您已使用AwesomeProject
名称初始化项目,不是吗?那么为什么要按movieView
名称注册组件?将其替换为AwesomeProject
字符串。或者更改您的ios项目AppDelegate.m
文件。
必须有这样的命令
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"AwesomeProject"
initialProperties:nil
launchOptions:launchOptions];
将moduleName:@"AwesomeProject"
替换为moduleName:@"movieView"
。
不要忘记重新启动开发服务器。
P.S。似乎这个问题不再是实际的了,哈哈?