文章詳情頁
javascript - 新建js文件時(shí)如何自動(dòng)地加上"use strict"?
瀏覽:345日期:2024-03-31 16:51:32
問題描述
setline(1,''use strict'')不行。
問題解答
回答1:使用自動(dòng)化構(gòu)建工具 gulp 配置好后可以直接寫 ES6
回答2:function! s:add_title() if &filetype == ’javascript’ call setline(1, ’use strict’) call append(line(’.’), ’’) endifendfunctionautocmd BufNewFile *.js execute 'call s:add_title()'
這個(gè)方便以后為其他類型的文件添加相似的功能, 參見 Vim 新建文件時(shí)自動(dòng)添加文件頭
或者僅針對(duì)這個(gè)使用場(chǎng)景:
function! s:add_title_js() call setline(1,’use strict’) call append(line(’.’), ’’)endfunctionautocmd FileType javascript execute 'call s:add_title_js()'回答3:
用的什么編輯器?
標(biāo)簽:
JavaScript
相關(guān)文章:
1. docker 下面創(chuàng)建的IMAGE 他們的 ID 一樣?這個(gè)是怎么回事????2. html5和Flash對(duì)抗是什么情況?3. docker 17.03 怎么配置 registry mirror ?4. html5 - datatables 加載不出來數(shù)據(jù)。5. 運(yùn)行python程序時(shí)出現(xiàn)“應(yīng)用程序發(fā)生異常”的內(nèi)存錯(cuò)誤?6. node.js - mongodb查找子對(duì)象的名稱為某個(gè)值的對(duì)象的方法7. 測(cè)試自動(dòng)化html元素選擇器元素ID或DataAttribute [關(guān)閉]8. javascript - QQ第三方登錄的問題9. spring-mvc - spring-session-redis HttpSessionListener失效10. javascript - 在 model里定義的 引用表模型時(shí),model為undefined。
排行榜

熱門標(biāo)簽
網(wǎng)公網(wǎng)安備