大树哥
大树哥
  • 发布:2015-06-25 18:46
  • 更新:2015-06-25 18:46
  • 阅读:2202

常见问题整理

分类:HBuilder

querySelectorAll的结果遍历时对象为空

document.querySelectorAll(".box")得到的不是数组,是nodelist,虽然可以类似数组的for,但真的不是数组,不能直接对其使用数组的方法forEach,如果我们需要转换为数组,我们可以用Array.prototype.slice.call来辅助就可以了。

https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/

var divs = document.querySelectorAll('div');  

[].forEach.call(divs, function(div) {  
  // do whatever  
  div.style.color = "red";  
});

Android平台通过native.js实现接收系统消息,如监听安装卸载apk事件

http://ask.dcloud.net.cn/article/222

1 关注 分享
2***@qq.com

要回复文章请先登录注册