百度、去哪儿网console.log发布招聘信息怎么搞呢?
打开console控制台能直接看到有些网站的招聘信息直接显示在控制台里,比如百度、去哪儿网。这些怎么搞呢?先看下官方的API吧console.log() 官方APIFormat SpecifierDescription%sFor...
·
打开console控制台能直接看到有些网站的招聘信息直接显示在控制台里,比如百度、去哪儿网。这些怎么搞呢?先看下官方的API吧
console.log() 官方API
Format Specifier | Description |
---|---|
%s | Formats the value as a string. |
%d or %i | Formats the value as an integer. |
%f | Formats the value as a floating point value. |
%o | Formats the value as an expandable DOM element (as in the Elements panel). |
%O | Formats the value as an expandable JavaScript object. |
%c | Formats the output string according to CSS styles you provide. |
直接上代码
if (window.console) {
console.log('你好\n\n\n欢迎你。');
console.log("css样式%c这里会变色", "color:red;font-weight:bold;");
}
如果需要图片也可以用css去引入
if (window.console) {
console.log("%c图片显示","padding-left:120px; padding-bottom:40px; background:url('路径') no-repeat")
}
当然也可以经过一些处理用字符串显示
通过这个网站patorjk.com生成字符串形式的图画
Function.prototype.makeMulti = function () {
let l = new String(this)
l = l.substring(l.indexOf("/*") + 3, l.lastIndexOf("*/"))
return l
}
let string = function () {
/* 你复制patorjk.com上的字符图案 */
}
console.log(string.makeMulti());
//也可以这样
console.log(`%c${string.makeMulti()}`,'color:red');
更多推荐
已为社区贡献1条内容
所有评论(0)