小编qas*_*ali的帖子

this.props.children在使用react-router-redux时未定义

我已经在github页面上跟随了react-router-redux示例,但是当我尝试传递{this.props.children}IndexRoute我并尝试记录它时,它是未定义的.

我通过控制台获得的唯一错误是Warning: You should not use <Route component> and <Route children> in the same route; <Route children> will be ignored,通过谷歌搜索此错误,它只是其中一个错误,人们说只是忽略它,因为它不会影响任何代码(由于某种原因).

package.json

....
"react": "^0.14.7",
"react-redux": "^4.4.0",
"react-router": "^4.0.0",
"react-router-dom": "^4.0.0",
"react-router-redux": "^4.0.8",
"redux": "^3.3.1",
"redux-thunk": "^1.0.3"
...
Run Code Online (Sandbox Code Playgroud)

routes.js

import React from 'react';
import { Route, IndexRoute } from 'react-router';

import Items from "./components/Items"
import App1Container from "./containers/App1Container";
import ItemDetailContainer from "./containers/ItemDetailContainer";

export default (
  <Route path="/" component={App1Container}>
    <IndexRoute component={Items} />
        <Route path="i/:id" …
Run Code Online (Sandbox Code Playgroud)

javascript react-router-redux

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

处理对话流中的音频播放完成回调(媒体响应)

我正在通过播放MediaObject. 我想创建一个意图处理程序来捕获媒体播放完成的回调,文档显示了一个关于如何编写实现代码来处理它的示例。

建立你的成就感

下面的代码片段展示了如何为 Action 编写执行代码。如果您使用 Dialogflow,请将 actions.intent.MEDIA_STATUS 替换为接收 actions_intent_MEDIA_STATUS 事件的意图中指定的操作名称(例如,“media.status.update”)。

我对对话流说明的部分感到困惑。我处理并返回 MediaObject 的意图被调用,smoothie-02并且我有一个后备,它在媒体播放完毕后得到处理,但我想创建另一个意图并在那里处理它。我想要做的是创建一个新的意图来处理它,而不是它去意图的后备smoothie-02意图。

smoothie-02 处理程序

app.dialogFlow.intent('smoothie-02', (conv) => {
    const welcomeContext = getConvContext(conv, AppContexts.WELCOME);

    givenName = welcomeContext.parameters['given-name'];
    fruitTypes = welcomeContext.parameters['FruitTypes'];

    if (!conv.surface.capabilities.has('actions.capability.MEDIA_RESPONSE_AUDIO')) {
        conv.ask('Sorry, this device does not support audio playback.');
        return;
    }

    conv.contexts.set("actions_capability_media_response_audio", 5);

    // Zoe says something
    let response = `Ooh good choice ${givenName} ! `;
    response += fruitTypes.length > 1 ? `${fruitTypes[0]} and ${fruitTypes[1]}` : `${fruitTypes[0]} `;
    response …
Run Code Online (Sandbox Code Playgroud)

node.js actions-on-google dialogflow-es

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

将Google字体添加到Flask

所以用flask我知道我可以添加CSS

<link ... href="{{ url_for('static', filename='stylesheets/style.css') }}" />
Run Code Online (Sandbox Code Playgroud)

但是,如果我要添加通常以HTML格式显示的Google字体,

<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
Run Code Online (Sandbox Code Playgroud)

要与Flask一起使用,我需要编辑/添加什么?

css python fonts flask

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

foreach异步睡眠方法

我正在尝试使我的 foreach 循环异步。循环第一次循环,做一些事情,然后它会等待 40 秒,然后循环再次循环做一些事情,等待 40 秒等等......

在我的情况下,我在推文中循环,获取推文用户名,然后向他们发送推文。我尝试使用该Thread.Sleep(40000)方法,但这只是冻结了应用程序,我无法使用它,并且循环不会停止 40 秒然后再次循环。应用程序冻结但循环没有,推文甚至没有等待就被发送。这是我的代码的样子

private void tweetButton_Click(object sender, EventArgs e)
{
            var tweets= .........
            foreach (var tweet in tweets)
            {
                // Do Something
                System.Threading.Thread.Sleep(40000);

 }
Run Code Online (Sandbox Code Playgroud)

我如何让 foreach 循环在它自己再次循环之前暂停,我如何让它暂停而不冻结我的应用程序?

c# visual-studio winforms

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

DateTime.Compare无法按预期工作

我试图比较两个DateTime对象忽略秒与下面的函数,但它给出了错误的结果,即使两个DateTime对象具有相同的值.无法弄清楚如何使其正常工作,任何帮助将受到高度赞赏.

public static int CompareDateTime(DateTime d1, DateTime d2)
{
    d1 = d1.AddSeconds(-1 * d1.Second);
    d2 = d2.AddSeconds(-1 * d2.Second);

    int result = DateTime.Compare(d1, d2);
    string relationship;

    if (result < 0)
        relationship = "is earlier than";
    else if (result == 0)
        relationship = "is the same time as";
    else
        relationship = "is later than";

    Console.WriteLine("{0} {1} {2}", d1, relationship, d2);

    return result;

}
Run Code Online (Sandbox Code Playgroud)

结果:

3/7/2017 2:54:00 PM is later than 3/7/2017 2:54:00 PM
Run Code Online (Sandbox Code Playgroud)

.net c# datetime

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