Home >WeChat Applet >Mini Program Development >How to use js to count the number of page tags
This time I will show you how to use js to count the number of page tags, and what are the precautions for using js to count the number of page tags. The following is a practical case, let's take a look.
The specific code is as follows:function fold(node){ var map = new Map(); map.set(node.tagName,1); [].reduce.call(node.children,(acc,child)=>{ deal(acc,fold(child)); return acc },map) return map } function deal(srcMap,tarMap){ tarMap.forEach((value,tagName)=>{ var newV = value + ~~srcMap.get(tagName); srcMap.set(tagName,newV); }) }Calling I believe you have mastered the method after reading the case in this article, please come for more exciting information Pay attention to other related articles on php Chinese website! Recommended reading: ##Implement uploading images with backend code in WeChat applet
The above is the detailed content of How to use js to count the number of page tags. For more information, please follow other related articles on the PHP Chinese website!