小编Ara*_*oft的帖子

在Swift中每隔x分钟做一些事情

我怎么能每分钟运行一个功能?在JavaScript中我可以做类似的事情setInterval,在Swift中存在类似的东西吗?

通缉输出:

你好世界每分钟一次......

repeat intervals setinterval ios swift

102
推荐指数
6
解决办法
8万
查看次数

angularjs:如何向资源对象添加缓存?

在http中添加缓存非常简单.(通过传递cache = true)

http://docs.angularjs.org/api/ng.$http有Cache选项.

如何在angularjs中的$ resource中添加类似功能?

javascript angularjs

42
推荐指数
5
解决办法
4万
查看次数

Angular 2,主要组件内部的组件

我在angular.io上玩过angular 2演示.现在我想创建一个新组件并在我的应用程序中使用它.

我目前的应用:

import {Component, Template, bootstrap} from 'angular2/angular2';
import {UsersComponent} from './components/users/component.js';

// Annotation section
@Component({
  selector: 'my-app'
})
@Template({
  url:"app.html"
})
// Component controller
class MyAppComponent {
  newName:string;
  names:Array<string>;
  constructor() {
    this.name = 'Florian';
  }

  showAlert(){
    alert("It works");
  }

  addName(){
    names.push(newName);
    newName = "";
  }
}

bootstrap(MyAppComponent);
Run Code Online (Sandbox Code Playgroud)

我的组件:

import {Component, Template, bootstrap} from 'angular2/angular2';
// Annotation section
@Component({
  selector: 'users'
})
@Template({
  url:"./template.html"
})
// Component controller
class UsersComponent {
  newName:string;
  names:Array<string>;
  constructor() {

  }

  addName(){
    names.push(newName);
    newName …
Run Code Online (Sandbox Code Playgroud)

angular

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

margin-top和-webkit-margin-before之间有什么区别

Webkit添加了自己的特定边距:

-webkit-margin-before:
-webkit-margin-after:
-webkit-margin-start:
-webkit-margin-end:
Run Code Online (Sandbox Code Playgroud)

我理解(margin-left和-webkit-margin-start)或(margin-right和-webkit-margin-end)与"从左到右"或"从右到左"语言相关的区别.

我的问题是(margin-top和-webkit-margin-before)或(margin-bottom和-webkit-margin-after)之间有什么区别?

注意:很明显,-webkit前缀仅适用于webkit引擎浏览器,例如chrome和safari.这个问题与它无关.

html css webkit css3

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

什么是约束点验证@Null?

我检查可用约束的列表javax.validation包,我注意到,有一个注释@null迫使现场为空.

如果我已经知道它应该为null,我不明白将它添加到我的字段有什么意义.

例如,看看这个类:

public class MyClass{

    @NotNull
    private String myString1;

    @Null
    private String myString2;

    // getter setters...
}
Run Code Online (Sandbox Code Playgroud)

@NotNull完全有道理.我不希望myString1是空的.但@NullmyString2没用.有一个字段应始终为null的重点是什么.

constraints java-ee bean-validation

15
推荐指数
2
解决办法
4004
查看次数

在生产中调试缓存被破坏的脚本

我正在开发一个前端项目(JavaScript文件),服务器在URL的末尾添加一个缓存清除值,例如, http://www.example.com/myfile.js&bust=0.5647534393

我的问题是我在重新加载后丢失了Chrome开发者工具中设置的任何断点.我没有访问服务器来禁用它.

有没有办法解决这个约束?

更新:添加debugger;到JS源代码不是一个可行的解决方案,因为我正在调试生产代码.

javascript google-chrome-devtools

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

Angular 2 @Component语法是ES6的一部分吗?

有谁能告诉我.'@'导入的Component函数前面的符号.这是ES6语法吗?我没有看到它用于我看过的任何其他非角度ES6项目.

import {Component} from ...
@Component({})
Run Code Online (Sandbox Code Playgroud)

这是一个例子

typescript ecmascript-6 angular

7
推荐指数
3
解决办法
1525
查看次数

带有 StandardOpenOption.CREATE 的 Files.newInputStream 中的 NoSuchFileException

如果文件不存在,我正在尝试打开文件进行读取或创建文件。我使用这个代码:

String location = "/test1/test2/test3/";
new File(location).mkdirs();
location += "fileName.properties";
Path confDir = Paths.get(location);
InputStream in = Files.newInputStream(confDir, StandardOpenOption.CREATE);
in.close();
Run Code Online (Sandbox Code Playgroud)

我得到 java.nio.file.NoSuchFileException

考虑到我正在使用StandardOpenOption.CREATE选项,如果文件不存在,则应创建该文件。

知道为什么我会收到此异常吗?

java nio

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

JavaScript中forEach回调函数的第三个参数是什么?

我知道JavaScript 中的forEach使用三个参数调用我的回调函数:

arr.forEach(function callback(currentValue, index, array) {
    //your iterator
})
Run Code Online (Sandbox Code Playgroud)

在上面的例子arrarray是相同的阵列与arr存在于回调函数闭合.

现在问题是传递array给回调函数的重点是什么?

javascript arrays foreach

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

messageComposeViewController Swift 2中的错误

以下代码适用于Swift 1.2.现在,我收到一个错误:

"MessageComposeResult类型的值没有成员'值'"

func messageComposeViewController(controller: MFMessageComposeViewController, didFinishWithResult result: MessageComposeResult) {
    switch (result.value) {
    case MessageComposeResultCancelled.value:
        print("Message was cancelled")
        self.dismissViewControllerAnimated(true, completion: nil)
    case MessageComposeResultFailed.value:
        print("Message failed")
        self.dismissViewControllerAnimated(true, completion: nil)
    case MessageComposeResultSent.value:
        print("Message was sent")
        self.dismissViewControllerAnimated(true, completion: nil)
    default:
        break;
    }
}
Run Code Online (Sandbox Code Playgroud)

为了在Swift 2中找到消息的状态,我应该检查结果的哪个成员?

ios swift swift2

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