我正在document.createElement插入一个iframe,但无法设置allowTransparency。这是我正在使用的代码:
var iframe = document.createElement('iframe');
iframe.className = 'example';
iframe.allowTransparency = 'true';
iframe.frameBorder = '0';
iframe.scrolling = 'no';
iframe.style.width = '260px';
iframe.style.height = '120px';
iframe.style.border = 'none';
iframe.src = '//example.com/page';
document.body.appendChild(iframe);
Run Code Online (Sandbox Code Playgroud)
但是根据Web Inspector的输出仅为:
<iframe class="example" frameborder="0" scrolling="no" style="width: 260px; height: 120px; border: none; " src="//example.com/page"></iframe>
Run Code Online (Sandbox Code Playgroud) 如何将两个相对的数字范围相互映射?
我有一个带有三个数字的范围:( 1, 2, 3和任何可能的小数).
我想粗略地将其映射到1000到0的范围内.
所以1 = 1000,2 = 500,3 = 0.
最终,我想拿一个像1.68这样的数字,并找出它在1000-0规模上匹配的位置.
我有一个包含许多不同类的单个模块(分成单独的文件).每个类都有相同的集合attr_accessor,那么如何重用它而不必重复attr_accessor块?
我现在在做什么......
# dog.rb
module Animals
class Dog
attr_accessor :name, :color, :age
end
end
# cat.rb
module Animals
class Cat
attr_accessor :name, :color, :age
end
end
# rodent.rb
module Animals
class Rodent
attr_accessor :name, :color, :age
end
end
Run Code Online (Sandbox Code Playgroud)
我试着这样做没有运气......
# animals.rb
module Animals
attr_accessor :name, :color, :age
end
Run Code Online (Sandbox Code Playgroud)
我需要直接在我的应用程序中访问这些模块(这是一个Rails应用程序).例如:Animals::Dog.give_water
我在Rails 4应用程序中有以下一组收集路径:
resources :stats do
collection do
match 'mrr', via: [:get, :post]
match 'upgrades', via: [:get, :post]
match 'arpu', via: [:get, :post]
match 'arr', via: [:get, :post]
match 'ltv', via: [:get, :post]
end
end
Run Code Online (Sandbox Code Playgroud)
至少还有十几个这样的match线.
有没有办法压缩,所以我不再重复(特别是via方法选项)?
如何skip_after_filter处理if声明?
skip_after_filter :intercom_rails_auto_include if current_account.expired?
Run Code Online (Sandbox Code Playgroud)
我正在使用Rails 4.0.1.
我有一个ID数组,我想查询一下那些ID中尚不存在的ID。
拿着它:
spotify_ids = ['47k5tMDS3jLAOFE29nkfzO', '5mv8xuH3y6jxFCBT6a3w4K', '5En0gXQk01BaWoT4q2oVbe', '0cj44N6Ux4i2NkTkQIcLnE']
existing_items = Track.where(spotify_id: spotify_ids)
Run Code Online (Sandbox Code Playgroud)
在此示例中,该ID 0cj44N6Ux4i2NkTkQIcLnE不存在,因此我最终试图返回的是just ['0cj44N6Ux4i2NkTkQIcLnE']。
那where只是返回它找到的记录,而我试图指出它没有保存哪些ID 。
我试过了,Track.where.not(spotify_id: spotify_ids)但是只是返回了整个表中与这些ID不匹配的每条记录,这不是我要的。
阵列中最多只能包含50个项目,因此,一般而言,性能问题不会出现。