小编Den*_*nis的帖子

Marionette.js ItemView - 将子视图放在区域中

我有以下ItemView模板,其中填充了客户数据(firstName,lastName),我想CollectionView在div中添加一个.addresses.

模板

<script type="text/html" id="template-customer-details">
    <h4><%= firstName %> <%= lastName %></h4>
    <button class="edit">Edit</button>
    <h5>Addresses</h5>
    <div class="addresses">...</div>
</script>
Run Code Online (Sandbox Code Playgroud)

布局

Layout.Details = Backbone.Marionette.ItemView.extend({
    template: '#template-customer-details',

    regions: {
        addresses: ".addresses"
    },

    serializeData: function () {
        return this.model.attributes;
    },

    initialize: function () {

        this.addressList = new App.Models.AddressList();

        // Error!
        this.regions.addresses.show(this.addressList);

        this.bindTo(this, "render", this.$el.refresh, this.$el);
        this.model.bind("change", this.render.bind(this));
    }
});
Run Code Online (Sandbox Code Playgroud)

我收到错误"Uncaught TypeError:Object .addresses没有方法'show'."

我必须等到视图加载?

javascript backbone.js marionette

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

PHP中的安全导航操作符?

有没有办法用某种安全导航操作符编写以下语句?

echo $data->getMyObject() != null ? $data->getMyObject()->getName() : '';
Run Code Online (Sandbox Code Playgroud)

所以它看起来像这样:

echo $data->getMyObject()?->getName();
Run Code Online (Sandbox Code Playgroud)

php

6
推荐指数
3
解决办法
1953
查看次数

在C#中使用AccessType = Offline的Google Analytics OAuth

我想使用OAuth使用Google AnalyticsAPI.

我正在使用此库:http: //code.google.com/p/google-api-dotnet-client/

以下代码用于身份验证:

var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
    new ClientSecrets { ClientId = "...", ClientSecret = "..." },
    new[] {Google.Apis.Analytics.v3.AnalyticsService.Scope.AnalyticsReadonly},
    "user",
    CancellationToken.None,
    new FileDataStore("Analytics.Auth.Store")).Result;

var service = new Google.Apis.Analytics.v3.AnalyticsService(
    new BaseClientService.Initializer
    {
        HttpClientInitializer = credential,
        ApplicationName = "...",
    });
Run Code Online (Sandbox Code Playgroud)

我可以将它与refresh_token一起使用,这样我就不必每隔几天就接受一次授权请求吗?

类似于这个问题的答案: 服务帐户Google Analytics OAuth AccessType =离线C#

c# google-api-dotnet-client

3
推荐指数
2
解决办法
4218
查看次数

防止 React Native 快速刷新时 Redux 状态重置 (expo cli)

我试图了解如何将 React Native 快速刷新与 Redux 结合起来。我克隆了以下项目:https ://github.com/amandeepmittal/rnReduxhooks

当更改视图中的代码时,ViewNotes.js快速刷新效果很好。但是,当更改reducer中的代码时,notesApp.js 快速刷新会重置redux状态

我怎样才能防止这种情况发生?

有没有类似于 React 和 Redux 的 React Native 和 Redux 教程?(https://duske.me/setting-up-hot-module-replacement-with-create-react-app-and-redux/

动图

react-native react-redux

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

Packer Amazon EBS Chef - 抱歉,你必须有一个tty才能运行sudo

我想使用Packer为使用厨师的亚马逊ebs配置图像.

我收到以下错误消息:

sudo: sorry, you must have a tty to run sudo
Run Code Online (Sandbox Code Playgroud)

example.json

{
  "builders": [{
    "type": "amazon-ebs",
    "access_key": "...",
    "secret_key": "...",
    "region": "eu-central-1",
    "source_ami": "ami-daaeaec7",
    "instance_type": "t2.micro",
    "ssh_username": "ec2-user",
    "ami_name": "packer-example {{timestamp}}"
  }],
  "provisioners": [{
    "type": "chef-solo",
    "cookbook_paths": ["cookbooks", "site-cookbooks"],
    "run_list": [  ]
  }]
}
Run Code Online (Sandbox Code Playgroud)

产量

$ packer build example.json
amazon-ebs output will be in this color.

==> amazon-ebs: Prevalidating AMI Name...
==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Creating temporary keypair: packer ...
==> amazon-ebs: …
Run Code Online (Sandbox Code Playgroud)

linux packer amazon-web-services chef-infra

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