Console
about指令
Console API
日志
- log
可以自己定义CSS样式。
console.todo = function(msg) {
console.log(‘ % c % s % s % s‘, ‘color: yellow; background - color: black;’, ‘–‘, msg, ‘–‘);
}
console.important = function(msg) {
console.log(‘ % c % s % s % s’, ‘color: brown; font - weight: bold; text - decoration: underline;’, ‘–‘, msg, ‘–‘);
}
console.todo(“This is something that’ s need to be fixed”);
console.important(‘This is an important message’);
- info
- debug
- warn
- error
- table
时间性能
- time && timeEnd
- timeStamp
元素操作
- $
在Console中也可以使用来进行类似于querySelector那样基于CSS选择器的查询,$('css-selector') 会返回满足匹配的第一个元素,而$$('css-selector') 会返回全部匹配元素。注意,如果你会多次使用到元素,那么别忘了将它们存入变量中。
$0 - $4
$0可以获取当前元素
- 在元素中显示:在“Console”面板中右击 - 选择"Reveal in Elements Panel"
- $x(path)
- clear()
- copy(object)
- debug(function)
- undebug(function)
- dir(object)
- dirxml(object)
inspect(object/function)
在console中通过inspect和选择器配合,快速在Element中审查需要的元素。
getEventListeners(object)
- keys(object)
- values(object)
- monitor(function)
监测指定函数的调用情况以及参数。
- unmonitor(function)
- monitorEvents(object[, events])
- unmonitorEvents(object[, events])
- profile([name])
- profileEnd([name])
- Additional APIs
Network conditions
- 更改用户User Agent
- 模拟网络状态
Sensor
- 模拟定位(Emulate geolocation cordinates)
加速计(Emulate accelerometor)
- α represents the motion of the device around the z axis from 0 to 360 degrees.
- β represents the motion of the device around the x axis from -180 to 180 degrees - a front to back motion.
- γ represents the motion of the device around the y axis from -90 to 90 - a left to right motion.
Changing the values will trigger a deviceorientation event.