{"id":1838,"date":"2017-04-01T06:21:24","date_gmt":"2017-03-31T22:21:24","guid":{"rendered":"http:\/\/www.qdabc.cn\/?p=1838"},"modified":"2017-04-01T06:21:24","modified_gmt":"2017-03-31T22:21:24","slug":"firebug%e6%8e%a7%e5%88%b6%e5%8f%b0%e8%af%a6%e8%a7%a3-%e4%bd%9c%e8%80%85%ef%bc%9a%e9%98%ae%e4%b8%80%e5%b3%b0","status":"publish","type":"post","link":"http:\/\/www.qdabc.cn\/?p=1838","title":{"rendered":"Firebug\u63a7\u5236\u53f0\u8be6\u89e3 \u4f5c\u8005\uff1a\u962e\u4e00\u5cf0"},"content":{"rendered":"<p>\u63a7\u5236\u53f0\uff08Console\uff09\u662fFirebug\u7684\u7b2c\u4e00\u4e2a\u9762\u677f\uff0c\u4e5f\u662f\u6700\u91cd\u8981\u7684\u9762\u677f\uff0c\u4e3b\u8981\u4f5c\u7528\u662f\u663e\u793a\u7f51\u9875\u52a0\u8f7d\u8fc7\u7a0b\u4e2d\u4ea7\u751f\u5404\u7c7b\u4fe1\u606f\u3002<\/p>\n<p>\u4e00\u3001\u663e\u793a\u4fe1\u606f\u7684\u547d\u4ee4<\/p>\n<p>Firebug\u5185\u7f6e\u4e00\u4e2aconsole\u5bf9\u8c61\uff0c\u63d0\u4f9b5\u79cd\u65b9\u6cd5\uff0c\u7528\u6765\u663e\u793a\u4fe1\u606f\u3002<\/p>\n<p>\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662fconsole.log()\uff0c\u53ef\u4ee5\u7528\u6765\u53d6\u4ee3alert()\u6216document.write()\u3002\u6bd4\u5982\uff0c\u5728\u7f51\u9875\u811a\u672c\u4e2d\u4f7f\u7528console.log(&#8220;Hello World&#8221;)\uff0c\u52a0\u8f7d\u65f6\u63a7\u5236\u53f0\u5c31\u4f1a\u81ea\u52a8\u663e\u793a\u5982\u4e0b\u5185\u5bb9\u3002<br \/>\n\u53e6\u5916\uff0c\u6839\u636e\u4fe1\u606f\u7684\u4e0d\u540c\u6027\u8d28\uff0cconsole\u5bf9\u8c61\u8fd8\u67094\u79cd\u663e\u793a\u4fe1\u606f\u7684\u65b9\u6cd5\uff0c\u5206\u522b\u662f\u4e00\u822c\u4fe1\u606fconsole.info()\u3001\u9664\u9519\u4fe1\u606fconsole.debug()\u3001\u8b66\u544a\u63d0\u793aconsole.warn()\u3001\u9519\u8bef\u63d0\u793aconsole.error()\u3002<\/p>\n<p>\u6bd4\u5982\uff0c\u5728\u7f51\u9875\u811a\u672c\u4e2d\u63d2\u5165\u4e0b\u9762\u56db\u884c\uff1a<\/p>\n<p>console.info(&#8220;\u8fd9\u662finfo&#8221;);<\/p>\n<p>console.debug(&#8220;\u8fd9\u662fdebug&#8221;);<\/p>\n<p>console.warn(&#8220;\u8fd9\u662fwarn&#8221;);<\/p>\n<p>console.error(&#8220;\u8fd9\u662ferror&#8221;);<\/p>\n<p>\u52a0\u8f7d\u65f6\uff0c\u63a7\u5236\u53f0\u4f1a\u663e\u793a\u5982\u4e0b\u5185\u5bb9\u3002<br \/>\n\u53ef\u4ee5\u770b\u5230\uff0c\u4e0d\u540c\u6027\u8d28\u7684\u4fe1\u606f\u524d\u9762\u6709\u4e0d\u540c\u7684\u56fe\u6807\uff0c\u5e76\u4e14\u6bcf\u6761\u4fe1\u606f\u540e\u9762\u90fd\u6709\u8d85\u7ea7\u94fe\u63a5\uff0c\u70b9\u51fb\u540e\u8df3\u8f6c\u5230\u7f51\u9875\u6e90\u7801\u7684\u76f8\u5e94\u884c\u3002<\/p>\n<p>\u4e8c\u3001\u5360\u4f4d\u7b26<\/p>\n<p>console\u5bf9\u8c61\u7684\u4e0a\u97625\u79cd\u65b9\u6cd5\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528printf\u98ce\u683c\u7684\u5360\u4f4d\u7b26\u3002\u4e0d\u8fc7\uff0c\u5360\u4f4d\u7b26\u7684\u79cd\u7c7b\u6bd4\u8f83\u5c11\uff0c\u53ea\u652f\u6301\u5b57\u7b26\uff08%s\uff09\u3001\u6574\u6570\uff08%d\u6216%i\uff09\u3001\u6d6e\u70b9\u6570\uff08%f\uff09\u548c\u5bf9\u8c61\uff08%o\uff09\u56db\u79cd\u3002<\/p>\n<p>\u6bd4\u5982\uff0c<\/p>\n<p>console.log(&#8220;%d\u5e74%d\u6708%d\u65e5&#8221;,2011,3,26);<\/p>\n<p>console.log(&#8220;\u5706\u5468\u7387\u662f%f&#8221;,3.1415926);<br \/>\n%o\u5360\u4f4d\u7b26\uff0c\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u4e00\u4e2a\u5bf9\u8c61\u5185\u90e8\u60c5\u51b5\u3002\u6bd4\u5982\uff0c\u6709\u8fd9\u6837\u4e00\u4e2a\u5bf9\u8c61\uff1a<\/p>\n<p>var dog = {} ;<\/p>\n<p>dog.name = &#8220;\u5927\u6bdb&#8221; ;<\/p>\n<p>dog.color = &#8220;\u9ec4\u8272&#8221;;<\/p>\n<p>\u7136\u540e\uff0c\u5bf9\u5b83\u4f7f\u7528o%\u5360\u4f4d\u7b26\u3002<\/p>\n<p>console.log(&#8220;%o&#8221;,dog);<br \/>\n\u4e09\u3001\u5206\u7ec4\u663e\u793a<\/p>\n<p>\u5982\u679c\u4fe1\u606f\u592a\u591a\uff0c\u53ef\u4ee5\u5206\u7ec4\u663e\u793a\uff0c\u7528\u5230\u7684\u65b9\u6cd5\u662fconsole.group()\u548cconsole.groupEnd()\u3002<\/p>\n<p>console.group(&#8220;\u7b2c\u4e00\u7ec4\u4fe1\u606f&#8221;);<\/p>\n<p>console.log(&#8220;\u7b2c\u4e00\u7ec4\u7b2c\u4e00\u6761&#8221;);<\/p>\n<p>console.log(&#8220;\u7b2c\u4e00\u7ec4\u7b2c\u4e8c\u6761&#8221;);<\/p>\n<p>console.groupEnd();<\/p>\n<p>console.group(&#8220;\u7b2c\u4e8c\u7ec4\u4fe1\u606f&#8221;);<\/p>\n<p>console.log(&#8220;\u7b2c\u4e8c\u7ec4\u7b2c\u4e00\u6761&#8221;);<\/p>\n<p>console.log(&#8220;\u7b2c\u4e8c\u7ec4\u7b2c\u4e8c\u6761&#8221;);<\/p>\n<p>console.groupEnd();<br \/>\n\u70b9\u51fb\u7ec4\u6807\u9898\uff0c\u8be5\u7ec4\u4fe1\u606f\u4f1a\u6298\u53e0\u6216\u5c55\u5f00\u3002<br \/>\n\u56db\u3001console.dir()<\/p>\n<p>console.dir()\u53ef\u4ee5\u663e\u793a\u4e00\u4e2a\u5bf9\u8c61\u6240\u6709\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u3002<\/p>\n<p>\u6bd4\u5982\uff0c\u73b0\u5728\u4e3a\u7b2c\u4e8c\u8282\u7684dog\u5bf9\u8c61\uff0c\u6dfb\u52a0\u4e00\u4e2abark()\u65b9\u6cd5\u3002<\/p>\n<p>dog.bark = function(){alert(&#8220;\u6c6a\u6c6a\u6c6a&#8221;);};<\/p>\n<p>\u7136\u540e\uff0c\u663e\u793a\u8be5\u5bf9\u8c61\u7684\u5185\u5bb9\uff0c<\/p>\n<p>console.dir(dog);<br \/>\n\u4e94\u3001console.dirxml()<\/p>\n<p>console.dirxml()\u7528\u6765\u663e\u793a\u7f51\u9875\u7684\u67d0\u4e2a\u8282\u70b9\uff08node\uff09\u6240\u5305\u542b\u7684html\/xml\u4ee3\u7801\u3002<\/p>\n<p>\u6bd4\u5982\uff0c\u5148\u83b7\u53d6\u4e00\u4e2a\u8868\u683c\u8282\u70b9\uff0c<\/p>\n<p>var table = document.getElementById(&#8220;table1&#8221;);<\/p>\n<p>\u7136\u540e\uff0c\u663e\u793a\u8be5\u8282\u70b9\u5305\u542b\u7684\u4ee3\u7801\u3002<\/p>\n<p>console.dirxml(table);<br \/>\n\u516d\u3001console.assert()<\/p>\n<p>console.assert()\u7528\u6765\u5224\u65ad\u4e00\u4e2a\u8868\u8fbe\u5f0f\u6216\u53d8\u91cf\u662f\u5426\u4e3a\u771f\u3002\u5982\u679c\u7ed3\u679c\u4e3a\u5426\uff0c\u5219\u5728\u63a7\u5236\u53f0\u8f93\u51fa\u4e00\u6761\u76f8\u5e94\u4fe1\u606f\uff0c\u5e76\u4e14\u629b\u51fa\u4e00\u4e2a\u5f02\u5e38\u3002<\/p>\n<p>\u6bd4\u5982\uff0c\u4e0b\u9762\u4e24\u4e2a\u5224\u65ad\u7684\u7ed3\u679c\u90fd\u4e3a\u5426\u3002<\/p>\n<p>var result = 0;<\/p>\n<p>console.assert( result );<\/p>\n<p>var year = 2000;<\/p>\n<p>console.assert(year == 2011 );<br \/>\n\u4e03\u3001console.trace()<\/p>\n<p>console.trace()\u7528\u6765\u8ffd\u8e2a\u51fd\u6570\u7684\u8c03\u7528\u8f68\u8ff9\u3002<\/p>\n<p>\u6bd4\u5982\uff0c\u6709\u4e00\u4e2a\u52a0\u6cd5\u5668\u51fd\u6570\u3002<\/p>\n<p>function add(a,b){<\/p>\n<p>return a+b;<\/p>\n<p>}<\/p>\n<p>\u6211\u60f3\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u662f\u5982\u4f55\u88ab\u8c03\u7528\u7684\uff0c\u5728\u5176\u4e2d\u52a0\u5165console.trace()\u65b9\u6cd5\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>function add(a,b){<\/p>\n<p>console.trace();<\/p>\n<p>return a+b;<\/p>\n<p>}<\/p>\n<p>\u5047\u5b9a\u8fd9\u4e2a\u51fd\u6570\u7684\u8c03\u7528\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>var x = add3(1,1);<\/p>\n<p>function add3(a,b){return add2(a,b);}<\/p>\n<p>function add2(a,b){return add1(a,b);}<\/p>\n<p>function add1(a,b){return add(a,b);}<\/p>\n<p>\u8fd0\u884c\u540e\uff0c\u4f1a\u663e\u793aadd()\u7684\u8c03\u7528\u8f68\u8ff9\uff0c\u4ece\u4e0a\u5230\u4e0b\u4f9d\u6b21\u4e3aadd()\u3001add1()\u3001add2()\u3001add3()\u3002<br \/>\n\u516b\u3001\u8ba1\u65f6\u529f\u80fd<\/p>\n<p>console.time()\u548cconsole.timeEnd()\uff0c\u7528\u6765\u663e\u793a\u4ee3\u7801\u7684\u8fd0\u884c\u65f6\u95f4\u3002<\/p>\n<p>console.time(&#8220;\u8ba1\u65f6\u5668\u4e00&#8221;);<\/p>\n<p>for(var i=0;i&lt;1000;i++){<\/p>\n<p>for(var j=0;j&lt;1000;j++){}<\/p>\n<p>}<\/p>\n<p>console.timeEnd(&#8220;\u8ba1\u65f6\u5668\u4e00&#8221;);<br \/>\n\u4e5d\u3001\u6027\u80fd\u5206\u6790<\/p>\n<p>\u6027\u80fd\u5206\u6790\uff08Profiler\uff09\u5c31\u662f\u5206\u6790\u7a0b\u5e8f\u5404\u4e2a\u90e8\u5206\u7684\u8fd0\u884c\u65f6\u95f4\uff0c\u627e\u51fa\u74f6\u9888\u6240\u5728\uff0c\u4f7f\u7528\u7684\u65b9\u6cd5\u662fconsole.profile()\u3002<\/p>\n<p>\u5047\u5b9a\u6709\u4e00\u4e2a\u51fd\u6570Foo()\uff0c\u91cc\u9762\u8c03\u7528\u4e86\u53e6\u5916\u4e24\u4e2a\u51fd\u6570funcA()\u548cfuncB()\uff0c\u5176\u4e2dfuncA()\u8c03\u752810\u6b21\uff0cfuncB()\u8c03\u75281\u6b21\u3002<\/p>\n<p>function Foo(){<\/p>\n<p>for(var i=0;i&lt;10;i++){funcA(1000);}<\/p>\n<p>funcB(10000);<\/p>\n<p>}<\/p>\n<p>function funcA(count){<\/p>\n<p>for(var i=0;i&lt;count;i++){}<\/p>\n<p>}<\/p>\n<p>function funcB(count){<\/p>\n<p>for(var i=0;i&lt;count;i++){}<\/p>\n<p>}<\/p>\n<p>\u7136\u540e\uff0c\u5c31\u53ef\u4ee5\u5206\u6790Foo()\u7684\u8fd0\u884c\u6027\u80fd\u4e86\u3002<\/p>\n<p>console.profile(&#8216;\u6027\u80fd\u5206\u6790\u5668\u4e00&#8217;);<\/p>\n<p>Foo();<\/p>\n<p>console.profileEnd();<\/p>\n<p>\u63a7\u5236\u53f0\u4f1a\u663e\u793a\u4e00\u5f20\u6027\u80fd\u5206\u6790\u8868\uff0c\u5982\u4e0b\u56fe\u3002<br \/>\n\u6807\u9898\u680f\u63d0\u793a\uff0c\u4e00\u5171\u8fd0\u884c\u4e8612\u4e2a\u51fd\u6570\uff0c\u5171\u8017\u65f62.656\u6beb\u79d2\u3002\u5176\u4e2dfuncA()\u8fd0\u884c10\u6b21\uff0c\u8017\u65f61.391\u6beb\u79d2\uff0c\u6700\u77ed\u8fd0\u884c\u65f6\u95f40.123\u6beb\u79d2\uff0c\u6700\u957f0.284\u6beb\u79d2\uff0c\u5e73\u57470.139\u6beb\u79d2\uff1bfuncB()\u8fd0\u884c1\u6b21\uff0c\u8017\u65f61.229ms\u6beb\u79d2\u3002<\/p>\n<p>\u9664\u4e86\u4f7f\u7528console.profile()\u65b9\u6cd5\uff0cfirebug\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a&#8221;\u6982\u51b5&#8221;\uff08Profiler\uff09\u6309\u94ae\u3002\u7b2c\u4e00\u6b21\u70b9\u51fb\u8be5\u6309\u94ae\uff0c&#8221;\u6027\u80fd\u5206\u6790&#8221;\u5f00\u59cb\uff0c\u4f60\u53ef\u4ee5\u5bf9\u7f51\u9875\u8fdb\u884c\u67d0\u79cd\u64cd\u4f5c\uff08\u6bd4\u5982ajax\u64cd\u4f5c\uff09\uff0c\u7136\u540e\u7b2c\u4e8c\u6b21\u70b9\u51fb\u8be5\u6309\u94ae\uff0c&#8221;\u6027\u80fd\u5206\u6790&#8221;\u7ed3\u675f\uff0c\u8be5\u64cd\u4f5c\u5f15\u53d1\u7684\u6240\u6709\u8fd0\u7b97\u5c31\u4f1a\u8fdb\u884c\u6027\u80fd\u5206\u6790\u3002<br \/>\n\u5341\u3001\u5c5e\u6027\u83dc\u5355<\/p>\n<p>\u63a7\u5236\u53f0\u9762\u677f\u7684\u540d\u79f0\u540e\u9762\uff0c\u6709\u4e00\u4e2a\u5012\u4e09\u89d2\uff0c\u70b9\u51fb\u540e\u4f1a\u663e\u793a\u5c5e\u6027\u83dc\u5355\u3002<br \/>\n\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u63a7\u5236\u53f0\u53ea\u663e\u793aJavascript\u9519\u8bef\u3002\u5982\u679c\u9009\u4e2dJavascript\u8b66\u544a\u3001CSS\u9519\u8bef\u3001XML\u9519\u8bef\u90fd\u9001\u4e0a\uff0c\u5219\u76f8\u5173\u7684\u63d0\u793a\u4fe1\u606f\u90fd\u4f1a\u663e\u793a\u3002<\/p>\n<p>\u8fd9\u91cc\u6bd4\u8f83\u6709\u7528\u7684\u662f&#8221;\u663e\u793aXMLHttpRequests&#8221;\uff0c\u4e5f\u5c31\u662f\u663e\u793aajax\u8bf7\u6c42\u3002\u9009\u4e2d\u4ee5\u540e\uff0c\u7f51\u9875\u7684\u6240\u6709ajax\u8bf7\u6c42\uff0c\u90fd\u4f1a\u5728\u63a7\u5236\u53f0\u9762\u677f\u663e\u793a\u51fa\u6765\u3002<\/p>\n<p>\u6bd4\u5982\uff0c\u70b9\u51fb\u4e00\u4e2aYUI\u793a\u4f8b\uff0c\u63a7\u5236\u53f0\u5c31\u4f1a\u544a\u8bc9\u6211\u4eec\uff0c\u5b83\u7528ajax\u65b9\u5f0f\u53d1\u51fa\u4e86\u4e00\u4e2aGET\u8bf7\u6c42\uff0chttp\u8bf7\u6c42\u548c\u54cd\u5e94\u7684\u5934\u4fe1\u606f\u548c\u5185\u5bb9\u4e3b\u4f53\uff0c\u4e5f\u90fd\u53ef\u4ee5\u770b\u5230\u3002<\/p>\n<p class=\"post-copyright\">\u6b22\u8fce\u5206\u4eab\u672c\u6587\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u51fa\u5904\uff1a<a href=\"http:\/\/www.qdabc.cn\">\u524d\u7aefABC<\/a> &raquo; <a href=\"http:\/\/www.qdabc.cn\/?p=1838\">Firebug\u63a7\u5236\u53f0\u8be6\u89e3 \u4f5c\u8005\uff1a\u962e\u4e00\u5cf0<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u63a7\u5236\u53f0\uff08Console\uff09\u662fFirebug\u7684\u7b2c\u4e00\u4e2a\u9762\u677f\uff0c\u4e5f\u662f\u6700\u91cd\u8981\u7684\u9762\u677f\uff0c\u4e3b\u8981\u4f5c\u7528\u662f\u663e\u793a\u7f51\u9875\u52a0\u8f7d\u8fc7\u7a0b\u4e2d\u4ea7\u751f\u5404\u7c7b\u4fe1\u606f\u3002 \u4e00\u3001\u663e\u793a\u4fe1\u606f\u7684\u547d\u4ee4 Firebug\u5185\u7f6e\u4e00\u4e2aconsole\u5bf9\u8c61\uff0c\u63d0\u4f9b5\u79cd\u65b9\u6cd5\uff0c\u7528\u6765\u663e\u793a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/1838"}],"collection":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1838"}],"version-history":[{"count":1,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/1838\/revisions"}],"predecessor-version":[{"id":1839,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/1838\/revisions\/1839"}],"wp:attachment":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1838"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}