小编wma*_*ley的帖子

如何在Elm中创建HTML数据属性?

我需要使用自定义"data-*"属性标记我的Elm.Http元素,例如:

<tr data-row="1">...</tr>
Run Code Online (Sandbox Code Playgroud)

我尝试过以下方法:

import Html exposing (..)
import Html.Attributes exposing (..)
import Json.Encode as JsEncode

view ... =
  tr [ property "data-row" (JsEncode.string (toString 1)) ]
Run Code Online (Sandbox Code Playgroud)

但这没有任何作用.有人知道吗?

我认为问题是Elm实际上是在设置JavaScript DOM属性,所以我真的想以某种方式调用element.dataset.row ="1".

背景是我需要为我的事件处理程序向jQuery公开一些数据,因为Elm事件库缺少一些我需要的功能,例如条件化的preventDefault和表单序列化.还有其他方法可以通过DOM提供数据,但data-*属性是迄今为止最简单的.

elm

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

榆木0.19:编译时elm会产生"不够字节"的错误

编译我的应用程序时,我突然收到此错误消息:

elm make  src/App.elm --output ../assets/javascripts/elm/App.js
elm: not enough bytes
CallStack (from HasCallStack):
  error, called at libraries/binary/src/Data/Binary.hs:212:21 in binary-0.8.5.1:Data.Binary
make: *** [App.js] Error 1
Run Code Online (Sandbox Code Playgroud)

编译错误?

编辑:解决方法是删除elm-stuff.然后它将编译一次,并在下次尝试时具有相同的错误.

elm

6
推荐指数
0
解决办法
478
查看次数

Rails 5 系统测试不会留在后台!(水豚含硒和铬)

当我运行大量 Capybara“系统”测试时,自动 Chrome 窗口不断成为焦点!这基本上意味着我在测试运行时无法工作。这让我发疯。有什么我可以做的吗?直到最近它才这样做。

宝石:

  • 导轨 5.2.0
  • 水豚3.0.3
  • 硒-webdriver 3.12.0
  • chromedriver-helper 1.2.0

ruby-on-rails capybara selenium-chromedriver ruby-on-rails-5

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

Spring Boot - 如何验证相互依赖的字段?

Spring Boot 中是否有某种方法可以对依赖于彼此值的属性执行验证,并使错误消息与该属性关联?

我想以漂亮的 JSON 结构将错误返回给用户:

{
  "errors": {
    "name": "is required if flag is true"
  }
}
Run Code Online (Sandbox Code Playgroud)

例子:

@Entity
public class MyEntity {
  private boolean nameRequiredFlag;

  // Required if "nameRequiredFlag" is set to true:
  private String name;
}
Run Code Online (Sandbox Code Playgroud)

无法解决将错误消息与 name 属性关联的问题的一种解决方案是为实体创建验证器注释:

@ValidEntity
public class MyEntity {
  private boolean nameRequiredFlag;

  // Required if "nameRequiredFlag" is set to true:
  private String name;
}

@Constraint( validatedBy = { MyEntityValidator.class } )
@Documented
@Target( { ElementType.TYPE } )
@Retention( RetentionPolicy.RUNTIME )
public …
Run Code Online (Sandbox Code Playgroud)

java spring-boot

5
推荐指数
2
解决办法
9072
查看次数

Rails 5.1 Puma 在生产模式下为空资产提供服务

我正在尝试在生产模式下测试我的 Rails 5.1 站点。我有预编译的资产,并设置了这个配置选项:config.public_file_server.enabled = true

问题是 Puma 正在以 200 状态提供零字节长度的 application.css 和 application.js,即使我仔细检查了这些文件是否存在并且已正确编译。

完整的配置/环境/production.rb:

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails ruby-on-rails-4 ruby-on-rails-5

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