设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 数据 手机
当前位置: 首页 > 综合聚焦 > 编程要点 > 正文

解析vscode中console.log的两种快速写法

发布时间:2021-11-17 15:44 所属栏目:13 来源:互联网
导读:(一)方法一:直接在script标签中提前定义,仅适用于该html文件! let add = function(a,b){ return a + b; }; console.log(add(20,300)); const { [log]:C } = console; C(add(20,300)); (二)方法二:按tab键快速生成console.log,且光标在()内部,再次按t
(一)方法一:直接在script标签中提前定义,仅适用于该html文件!
 
 let add = function(a,b){
  return a + b;
 };
 console.log(add(20,300));
 
 const { ['log']:C } = console;
 C(add(20,300));
(二)方法二:按tab键快速生成console.log,且光标在()内部,再次按tab键光标自动跳转到下一行!
打开vscode编辑器,选择文件->首选项->用户片段,输入javascript.json并按下enter进入。
初次使用我们会发现一段被注释的代码如下:
 
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
}

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读