小编dan*_*ane的帖子

如何将 html5 数据属性添加到 rails form_tag

如何将 html5 data- 属性添加到 rails form_tag

我知道您可以为 form_for 标签执行此操作,但它与 form_tag 的渲染方式不同:

<%= form_for(@inventory, :remote => true, :html => { 'data-parsley-validate' => "", "data-parsley-errors-container" => "#inventory_errors" }) do |f| %>
Run Code Online (Sandbox Code Playgroud)

html ruby ruby-on-rails ruby-on-rails-4

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

为什么total = total + i比total + = i快得多?

为什么total = total + i比total + = i快得多?这是我多次运行的代码:

var iterations = 1000000;
console.time('Operation total += i');
var total = 0;
for(var i = 0; i < iterations; i++ ){
    total += i;
};
console.timeEnd('Operation total += i');

console.time('Operation total = total + i');
var total = 0;
for(var i = 0; i < iterations; i++ ){
    total = total + i;
};
console.timeEnd('Operation total = total + i');
Run Code Online (Sandbox Code Playgroud)

以下是一些示例输出:

  • 操作总数+ = i:11.196ms
  • 操作总数=总+ i:9.561ms
  • 操作总数+ = i:15.135ms
  • 操作总数=总+ i:8.936ms

javascript performance google-chrome

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