小编tha*_*guy的帖子

从对象数组渲染React组件

我有一些叫做station的数据,它是一个包含对象的数组.

stations : [
  {call:'station one',frequency:'000'},
  {call:'station two',frequency:'001'}
]
Run Code Online (Sandbox Code Playgroud)

我想为每个数组位置渲染一个ui组件.到目前为止我可以写

 var stationsArr = []
 for (var i = 0; i < this.data.stations.length; i++) {
     stationsArr.push(
         <div className="station">
             {this.data}
         </div>
     )
 }
Run Code Online (Sandbox Code Playgroud)

然后渲染

render(){
 return (
   {stationsArr}
 )
}
Run Code Online (Sandbox Code Playgroud)

问题是我正在打印所有数据.我想要只显示一个键,{this.data.call}但不打印任何东西.

如何遍历此数据并为数组的每个位置返回一个新的UI元素?

javascript reactjs

82
推荐指数
3
解决办法
20万
查看次数

亚马逊S3桶返回403禁止

我最近继承了一个使用S3存储资产的Rails应用程序.我已将所有资产转移到我的S3存储桶,没有任何问题.但是,当我将应用程序更改为指向新存储桶时,我获得403 Forbidden Status.

我的S3存储桶设置了以下设置:

权限

每个人都可以列出

存储策略

{
 "Version": "2012-10-17",
 "Statement": [
    {
        "Sid": "PublicReadGetObject",
        "Effect": "Allow",
        "Principal": "*",
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::bucketname/*"
    }
 ]
}
Run Code Online (Sandbox Code Playgroud)

CORS配置

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
    </CORSRule>
    <CORSRule>
        <AllowedOrigin>https://www.appdomain.com</AllowedOrigin>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)

静态虚拟主机

启用.

我还能做些什么来让公众获得这些资产?

amazon-s3 amazon-web-services

46
推荐指数
4
解决办法
7万
查看次数

未配置 Meteor 登录服务

我正在使用 Meteor.loginWithFacebook 让用户访问我的应用程序。代码是

Meteor.loginWithFacebook({
    loginStyle:"redirect"
}, function(err){
    if (err) {
        throw err;
    }
    else{
        window.location = "/landing"
    }
});
Run Code Online (Sandbox Code Playgroud)

我的服务器有一个带有以下内容的 accounts.js:

ServiceConfiguration.configurations.remove({
  service: "facebook"
});
ServiceConfiguration.configurations.insert({
  service: "facebook",
  appId: "id",
  secret: "secret"
});
Run Code Online (Sandbox Code Playgroud)

它可以在桌面上运行,并且在捆绑到cordova 中时也可以运行,但突然之间,它无法运行并显示登录服务尚未配置的错误。

未捕获的错误:ServiceConfiguration.ConfigError:尚未加载登录服务配置:2199:http://meteor.local/packages/blaze.js

我一直看到Accounts.loginServicesConfigured()到处都提到,但没有看到文档中的解释,因此不知道如何使用它。

有什么帮助吗?

javascript cordova meteor

5
推荐指数
1
解决办法
2915
查看次数

ES2015模板字符串无法解析

我正在尝试在我的开发中使用ES6/ES2015功能,并尝试使用模板字符串代替串联.

我有一个名为的文件meteor.jsx,其中包含以下代码.

getLocation(lat,lon){
    return Meteor.http.call('GET','http://maps.googleapis.com/maps/api/geocode/json?latlng=${ lat },${ lon }&sensor=true&callback=zipmap')
}
Run Code Online (Sandbox Code Playgroud)

如果我用实际坐标称呼它

Meteor.call('getLocation','37.3175','-122.0419',function(e,r){}
Run Code Online (Sandbox Code Playgroud)

它不会转换lat或转换lon为字符串,只是在返回字符串中打印'$ {lat}'和'$ {lon}'.我究竟做错了什么?

javascript meteor ecmascript-6 template-strings

1
推荐指数
1
解决办法
246
查看次数