詳解vscode中console.log的兩種快速寫(xiě)法
(一)方法一:直接在script標(biāo)簽中提前定義,僅適用于該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,且光標(biāo)在()內(nèi)部,再次按tab鍵光標(biāo)自動(dòng)跳轉(zhuǎn)到下一行!
1、打開(kāi)vscode編輯器,選擇文件->首選項(xiàng)->用戶(hù)片段,輸入javascript.json并按下enter進(jìn)入。
初次使用我們會(huì)發(fā)現(xiàn)一段被注釋的代碼如下:
{ // 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" // } }
2、解除Example以下的區(qū)間代碼如下,其中部分參數(shù)意義如下:
①prefix:代碼快捷鍵的入口,在這里我們根據(jù)個(gè)人習(xí)慣進(jìn)行設(shè)置即可,如我設(shè)置的cl,那么配合tab健就可以直接生成console.log;
②body表示代碼主體:
$1表示生成代碼快速生成后后光標(biāo)首次出現(xiàn)的位置
$2寫(xiě)在"console.log('$1');"下面,表示在快速生成console.log()后,代碼后會(huì)空出一行,并且再次按tab鍵時(shí),光標(biāo)會(huì)跳轉(zhuǎn)到$2(空出的一行)的位置
{ // 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": "cl", "body": [ "console.log('$1');", "$2" ], "description": "Log output to console" } }
到此這篇關(guān)于vscode中console.log的兩種快速寫(xiě)法的文章就介紹到這了,更多相關(guān)vscode console.log寫(xiě)法內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Javascript中valueOf與toString區(qū)別淺析
Javascript中valueOf與toString區(qū)別淺析,需要的朋友可以參考一下2013-03-03使用pcs api往免費(fèi)的百度網(wǎng)盤(pán)上傳下載文件的方法
百度個(gè)人云盤(pán)空間大,完全免費(fèi),而且提供了pcs api供調(diào)用操作文件,在平時(shí)的項(xiàng)目里往里面保存一些文件是很實(shí)用的。通過(guò)本文給大家介紹使用pcs api往免費(fèi)的百度網(wǎng)盤(pán)上傳下載文件的方法,感興趣的朋友一起學(xué)習(xí)吧2016-03-03JavaScript中實(shí)現(xiàn)無(wú)縫滾動(dòng)、分享到側(cè)邊欄實(shí)例代碼
本文給通過(guò)js代碼實(shí)現(xiàn)無(wú)縫滾動(dòng),側(cè)邊欄效果,在項(xiàng)目中經(jīng)常會(huì)遇到,下面小編把代碼整理分享到腳本之家平臺(tái),供大家參考2016-04-04webpack3里使用uglifyjs壓縮js時(shí)打包報(bào)錯(cuò)的解決
這篇文章主要介紹了webpack3里使用uglifyjs壓縮js時(shí)打包報(bào)錯(cuò)的解決,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-12-12使用?TypeScript?開(kāi)發(fā)?React?函數(shù)式組件
這篇文章主要介紹了使用?TypeScript開(kāi)發(fā)React函數(shù)式組件,文章通過(guò)圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下2022-08-08原生js實(shí)現(xiàn)的移動(dòng)端可拖動(dòng)進(jìn)度條插件功能詳解
這篇文章主要介紹了原生js實(shí)現(xiàn)的移動(dòng)端可拖動(dòng)進(jìn)度條插件功能,結(jié)合實(shí)例形式詳細(xì)分析了javascript拖動(dòng)進(jìn)度條插件的具體定義與使用技巧,需要的朋友可以參考下2019-08-08