js调试的时候怎么在console中输出信息
2个回答
展开全部
用函数 console.log(...)
函数原型是:
console.log(obj1 [, obj2, ..., objN]);
console.log(msg [, subst1, ..., substN]);
例子:
<html><body>埋虚
<h2>Activate debugging with F12</h2>
<p>Select "Console" in the debugger menu. Then click Run again.<慧液樱/p>
<script>
console.log(5 + 6);
</script>
</body></html>
按F12键,起动debug,选Console,点Run 就见输出。
--
语句例子:var car = "Dodge Charger";
var someObject = {str:"前丛Some text", id:5};
console.info("My first car was a", car, ". The object is: ", someObject);
输出内容: My first car was a Dodge Charger . The object is: ({str:"Some text", id:5}
循环语句输出例子:for (var i=0; i<5; i++) {
console.log("Hello, %s. You've called me %d times.", "Bob", i+1);
}
输出有颜色的字体例子:
console.log("This is %cMy stylish message", "color: yellow; font-style: italic; background-color: blue;padding: 2px");
函数原型是:
console.log(obj1 [, obj2, ..., objN]);
console.log(msg [, subst1, ..., substN]);
例子:
<html><body>埋虚
<h2>Activate debugging with F12</h2>
<p>Select "Console" in the debugger menu. Then click Run again.<慧液樱/p>
<script>
console.log(5 + 6);
</script>
</body></html>
按F12键,起动debug,选Console,点Run 就见输出。
--
语句例子:var car = "Dodge Charger";
var someObject = {str:"前丛Some text", id:5};
console.info("My first car was a", car, ". The object is: ", someObject);
输出内容: My first car was a Dodge Charger . The object is: ({str:"Some text", id:5}
循环语句输出例子:for (var i=0; i<5; i++) {
console.log("Hello, %s. You've called me %d times.", "Bob", i+1);
}
输出有颜色的字体例子:
console.log("This is %cMy stylish message", "color: yellow; font-style: italic; background-color: blue;padding: 2px");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询