小编7ba*_*all的帖子

Angular 2在渲染元素后调用jQuery - 在使用API​​之后

我的Angular2应用程序使用RESTful API,然后<select>根据结果创建一堆元素.我试图在这些<select>元素上调用jQuery函数,但它看起来像jQuery函数执行得太迟了.我试过把功能放进去,ngAfterContentInit但是没用.把它ngAfterViewChecked冻结我的浏览器.

页面渲染后,如果我将jQuery函数粘贴到控制台中,一切正常,所以我知道我的函数和一切都是有用的.他们的订单可能搞砸了或其他什么.

在我的组件中:

ngOnInit() {
  this.myService.getAll().subscribe(
           data => this._data = data,
           error => this._error = "invalid.");
}

ngAfterViewInit() {
  $("select").select2(); // <--- jQuery function I need to execute after rendering
}
Run Code Online (Sandbox Code Playgroud)

在我的模板中:

<select *ngFor="let d of _data">...blah blah</select>
Run Code Online (Sandbox Code Playgroud)

javascript jquery angular

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

在情节提要中将LOTAnimationView与自动布局一起使用

有没有办法在LOTAnimationView自动布局中使用(Lottie框架)?我试过类的设置UIView,以LOTAnimationView我的故事板,但获得nilIB出口..

ios uistoryboard autolayout swift lottie

4
推荐指数
2
解决办法
1806
查看次数

如何在 Swift 或 Objective C 中将文本预先添加到文件中?

请注意,我不是在问如何在文件末尾附加文本。我在问如何在文件开头添加文本。

let handle = try FileHandle(forWritingTo: someFile)
//handle.seekToEndOfFile() // This is for appending
handle.seek(toFileOffset: 0) // Me trying to seek to the beginning of file
handle.write(content)
handle.closeFile()
Run Code Online (Sandbox Code Playgroud)

似乎 mycontent写在文件的开头,但它也只是取代了现有的同意......谢谢!

objective-c filehandle prepend nsfilehandle swift

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

PromiseKit实现和拒绝约定

我正在使用PromiseKit处理我的网络呼叫。我正在尝试查看是否有公约或更干净的方法尽早实现或拒绝诺言。如下所示,有一些条件要求我及早实现或拒绝。我目前正在通过在return随后发表声明来做到这一点。我觉得这很笨拙,想知道是否有更好的方法可以做到这一点。谢谢!

return PromiseKit { fulfill, reject in
  if statusCode == 200 {
    if conditionA {
      if conditionB {
        fulfill(...)  // How do I stop the execution chain from here
        return
      } else {
        reject(...) // Or here, without having to call return every time 
        return
      }
    }
    reject(...)
  }
}
Run Code Online (Sandbox Code Playgroud)

asynchronous swift promisekit

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

集成 Auth0 和 Hasura 时未找到访问被拒绝服务

我正在按照 Hasura 的文档使用 JWT 将登录功能与 Auth0 集成。我的 GraphQL 端点在控制台上运行良好。但是,当我尝试使用 Auth0 SDK 实现登录按钮时,出现以下错误:

{error: "access_denied", error_description: "Service not found: https://mydomain.herokuapp.com/v1/graphql", state: "T3FEQUpFRXFqX1RqcGQwaXpms3lXeEM3Rk80ZaQtLUp3bWdRQmVzLXpRaA=="}
Run Code Online (Sandbox Code Playgroud)

这是我失踪的明显事情吗?

reactjs auth0 graphql hasura

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

在同一个项目中使用私有 pod 和公共 pod

我刚刚将一个私人 Pod 推送到my.domain.com:apps/MyPrivatePod.git. 我想在我的项目中同时使用这个私有 Pod 和其他公共 Pod

platform :ios, '8.0'

target 'Testing' do
  pod 'AFNetworking', '2.6.0 ' // This is supposed to be a public Pod
  pod 'MyPrivatePod', '~> 1.1' // This is the private pod I talked about
end
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现这个目标?

git dependencies ios cocoapods cocoapods-1.2

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

选择表格中的行或列中的单选按钮

我有以下标记:

<table>
  <tr>
    <td><input type="radio" name="radio"></td>
    <td><input type="radio" name="radio"></td>
    <td><input type="radio" name="radio"></td>
  </tr>
  <tr>
    <td><input type="radio" name="radio"></td>
    <td><input type="radio" name="radio"></td>
    <td><input type="radio" name="radio"></td>
  </tr>
  <tr>
    <td><input type="radio" name="radio"></td>
    <td><input type="radio" name="radio"></td>
    <td><input type="radio" name="radio"></td>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

这是一张3x3的桌子,里面有9个单选按钮.我想配置它,以便我可以:

  • 每行选择1个单选按钮或
  • 每列选择1个单选按钮

这可能没有任何JavaScript吗?谢谢!

html javascript css radio-button

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

在Swift 3中覆盖属性

我想覆盖以下类中的属性.假设我有一个A具有布尔属性的类r.对于超类A,我希望r被设置并获得正常.对于子类B,我想r永远是false.我不确定为什么这比它应该更难......

class A {
    init(r: Bool) {
        self.r = r
    }

    var r: Bool {
        willSet(n) {
            r = n
        }
        get {
            return r
        }
    }
}

class B: A {
    override var r: Bool {
        willSet(n) {
            r = n
        }
        get {
            return false
        }
    }
}

let a = A(r: true)
a.r = false
print(a.r)  // prints 'false', which is good

let …
Run Code Online (Sandbox Code Playgroud)

inheritance getter-setter swift

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

导入为框架后,NSKeyedUnarchiver decodeObjectForKey崩溃

MyClass进入框架之前,我可以将实例保存MyClass到Core Data中.

这是实施MyClass:

open class MyClass: NSObject, NSCoding {
  required public init?(coder aDecoder: NSCoder) {
        super.init()
        stuffs = aDecoder.decodeObject(forKey: "stuff") as? [Stuff] ?? []
    }

    open func encode(with aCoder: NSCoder) {
        aCoder.encode(stuffs, forKey: "stuffs")
    }
}
Run Code Online (Sandbox Code Playgroud)

MyClass使用CocoaPods进入框架后,我开始遇到这些崩溃:

CoreData: error: exception handling request: <NSSQLFetchRequestContext: 0x1c019d4d0> , *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (MyClass) for key (NS.objects); the class may be defined in source code or a library that is not linked …
Run Code Online (Sandbox Code Playgroud)

core-data nscoding nscoder ios cocoapods

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