小编Ser*_*ver的帖子

用url和类来反应img标记问题

我的JSX文件中有以下简单的反应代码:

/** @jsx React.DOM */

var Hello = React.createClass({
    render: function() {
        return <div><img src='http://placehold.it/400x20&text=slide1' alt={event.title} class="img-responsive"/><span>Hello {this.props.name}</span></div>;
    }
});

React.renderComponent(<Hello name="World" />, document.body);
Run Code Online (Sandbox Code Playgroud)

DOM中的输出如下:

<div data-reactid=".0">
  <img src="http://placehold.it/400x20undefined1" data-reactid=".0.0">
  <span data-reactid=".0.1">
    <span data-reactid=".0.1.0">Hello </span>
    <span data-reactid=".0.1.1">World</span>
  </span>
</div>
Run Code Online (Sandbox Code Playgroud)

我有两个问题:

有任何想法吗?

javascript css reactjs

39
推荐指数
1
解决办法
13万
查看次数

将文件上传到Plunker

有没有办法将多个文件上传到http://plnkr.co,而不是一直复制粘贴代码?如果一个plunker可以连接到github存储库,或者如果可以拖入一组文件,那将会很棒.

plunker

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

TextBox中Windows窗体滚动日志输出的最佳方法

在Forms应用程序中,我正在显示生成大量输出的长时间运行的命令行应用程序的日志输出.我在后台启动程序,捕获其输出,并使用AppendText将其显示在TextBox中.我更喜欢只显示例如最后1000行.从TextBox中删除行是很昂贵的,而TextBox实际上并不是滚动日志显示的最佳方法.

关于在Windows窗体中执行滚动日志窗口的最佳控件的任何想法?

.net logging textbox winforms

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

AngularJS ui-router:强制重新加载

我有一个AngularJS应用程序从index.html开始并使用ui-router.基于触发器我想重新加载整个页面.我试过了:

$state.go($state.current, $stateParams, {
    reload: true,
    inherit: false,
    notify: true
});
Run Code Online (Sandbox Code Playgroud)

但这不起作用.它不会重新加载我的初始index.html.

我可以:

window.location.href = "index.html";
Run Code Online (Sandbox Code Playgroud)

但后来我在我的初始页面,而不是当前状态.

如果一组window.location.hrefindex.html与查询字符串参数指定的当前位置?如果我这样做,我该如何导航到这个位置?

angularjs angular-ui-router

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

具有反应的嵌入式JavaScript小部件

是否可以使用React JavaScript库创建可嵌入的JavaScript小部件,其中:

  1. React库在窗口小部件中"嵌入"
  2. 嵌入式React库的版本可以与加载窗口小部件的页面上的React库不同,就像使用jQuery一样.

我正在寻找以下所述的功能:

javascript widget reactjs

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

如何在管道中处理$ null

我的PowerShell代码中经常出现以下情况:我有一个返回对象集合的函数或属性,或者$null.如果将结果推送到管道中,则还要处理管道中的元素,如果$null它是唯一的元素.

例:

$Project.Features | Foreach-Object { Write-Host "Feature name: $($_.Name)" }
Run Code Online (Sandbox Code Playgroud)

如果没有功能($ Project.Features返回$ null),您将看到一行"功能名称:".

我看到三种解决方法:

if ($Project.Features -ne $null)
{
  $Project.Features | Foreach-Object { Write-Host "Feature name: $($_.Name)" }
}
Run Code Online (Sandbox Code Playgroud)

要么

$Project.Features | Where-Object {$_ -ne $null) | Foreach-Object { 
  Write-Host "Feature name: $($_.Name)" 
}
Run Code Online (Sandbox Code Playgroud)

要么

$Project.Features | Foreach-Object { 
  if ($_ -ne $null) {
    Write-Host "Feature name: $($_.Name)" }
  }
}
Run Code Online (Sandbox Code Playgroud)

但实际上我并不喜欢这些方法中的任何一种,但你认为最好的方法是什么?

powershell

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

最终的.NET文件和目录实用程序库?

我发现自己一直在编写文件和目录实用程序函数,我想知道是否有好的文件和目录库已经实现了比System.IO中默认的更广泛的集合.我正在寻找的功能类似于:

public static void GetTemporaryDirectory() 
{ 
   string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); 
   Directory.CreateDirectory(tempDirectory); 
   return tempDirectory; 
}

public static void CreateEmptyFile(string filename) 
{ 
    File.Create(filename).Dispose(); 
} 

public static void CreateEmptyFile(string path, string filename) 
{ 
    File.Create(Path.Combine(path, filename)).Dispose(); 
} 

public static void CreateDirectory(string path)
{
    Directory.CreateDirectory(path);
}

public static void CreateDirectory(string path, string childpath)
{
    Directory.CreateDirectory(Path.Combine(path, childpath));
}
Run Code Online (Sandbox Code Playgroud)

c# directory file

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

使用自定义PowerShell定义的类型进行参数类型规范

我使用New-Object定义自定义PowerShell类型.我希望参数是我定义的类型,是否可以以声明方式指定此类型?下面的代码给出了错误:"无法找到类型[BuildActionContext]:确保加载包含此类型的程序集."

我们可以指定声明类型,还是应该只测试指定对象的类型?

不工作的代码:

$buildActionContext = New-Object -TypeName PSObject -Property @{
# Given properties
BuildAction = "Build"; 
}
$buildActionContext.PSObject.TypeNames.Insert(0, 'BuildActionContext')

function DoSomethingWithBuildActionContext
{
[CmdletBinding()]
param
(
    [Parameter(Mandatory=$true)][BuildActionContext]$Context
)

Write-Host "Build action: $($Context.BuildAction)"
}

DoSomethingWithBuildActionContext -Context $buildActionContext
Run Code Online (Sandbox Code Playgroud)

工作代码,但可以不同的方式完成:

$buildActionContext = New-Object -TypeName PSObject -Property @{
        # Given properties
        BuildAction = "Build"; 
    }
    $buildActionContext.PSObject.TypeNames.Insert(0, 'BuildActionContext')

function DoSomethingWithBuildActionContext
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory=$true)]$Context
    )

    if ($Context.PSObject.TypeNames[0] -ne 'BuildActionContext')
    {
        throw "Context parameter not of type 'BuildActionContext'"
    }

    Write-Host "Build action: $($Context.BuildAction)"
}

DoSomethingWithBuildActionContext -Context …
Run Code Online (Sandbox Code Playgroud)

powershell

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

可以使用AngularJS和Typescript的Plunker?

我有一些代码我想问一下有关stackoverflow的问题.代码使用Typescript在AngularJS中编写,并操作和观察$ location.hash.我现在在https://github.com/svdoever/AngularJS-bookviewer上的github上有代码.是否可以在http://plnkr.co上获得此代码,最好不使用已编译的Typescript文件?

我在https://twitter.com/filearts/status/290961349092208642上读到,应该在http://plunkr.co上支持Typescript .

编辑:

Bassarat将gh-pages分支添加到git存储库的解决方案完成了这项工作.看到他的回答评论.

javascript angularjs typescript plunker

8
推荐指数
2
解决办法
5624
查看次数

渐进式 Web 应用程序是否可以将 Web 清单嵌入到 html 页面中?

我想通过如下嵌入来在我的 index.html 中提供指向清单文件的链接,但似乎不受支持。是否可以将清单描述嵌入网页中?

<link rel="manifest" href="data:application/manifest+json;base64,PCVAIFBhZ2UgQ29udGVudFR5cGU9ImFwcGxpY2F0aW9uL2pzb24iICU+DQp7DQoJIm5hbWUiOiAiU2hhcmVQb2ludCBUaXRsZSIsDQoJInNob3J0X25hbWUiOiAiU1AgVGl0bGUiLA0KCSJkZXNjcmlwdGlvbiI6ICJUaGUgb25lIGFuZCBvbmx5IFNoYXJlUG9pbnQgU2l0ZSBUaXRsZSBwcm9ncmFtISIsDQoJInN0YXJ0X3VybCI6ICJpbmRleC5odG1sIiwNCgkiaWNvbnMiOiBbDQoJCXsNCgkJCSJzcmMiOiAiYW5kcm9pZC1jaHJvbWUtMTQ0eDE0NC5wbmciLA0KCQkJInNpemVzIjogIjE0NHgxNDQiLA0KCQkJInR5cGUiOiAiaW1hZ2VcL3BuZyINCgkJfSwNCgkJew0KCQkJInNyYyI6ICJhbmRyb2lkLWNocm9tZS0xOTJ4MTkyLnBuZyIsDQoJCQkic2l6ZXMiOiAiMTkyeDE5MiIsDQoJCQkidHlwZSI6ICJpbWFnZVwvcG5nIg0KCQl9LA0KCQl7DQoJCQkic3JjIjogImFuZHJvaWQtY2hyb21lLTI1NngyNTYucG5nIiwNCgkJCSJzaXplcyI6ICIyNTZ4MjU2IiwNCgkJCSJ0eXBlIjogImltYWdlXC9wbmciDQoJCX0NCgldLA0KICAgICJiYWNrZ3JvdW5kIjogIiNmZjAwMDAiLA0KCSJ0aGVtZV9jb2xvciI6ICIjZmZmZmZmIiwNCgkiZGlzcGxheSI6ICJzdGFuZGFsb25lIg0KfQ0K">
Run Code Online (Sandbox Code Playgroud)

json progressive-web-apps

6
推荐指数
2
解决办法
2219
查看次数