文章詳情頁
javascript - 新建js文件時如何自動地加上"use strict"?
瀏覽:251日期:2024-03-31 16:51:32
問題描述
setline(1,''use strict'')不行。
問題解答
回答1:使用自動化構建工具 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()'
這個方便以后為其他類型的文件添加相似的功能, 參見 Vim 新建文件時自動添加文件頭
或者僅針對這個使用場景:
function! s:add_title_js() call setline(1,’use strict’) call append(line(’.’), ’’)endfunctionautocmd FileType javascript execute 'call s:add_title_js()'回答3:
用的什么編輯器?
標簽:
JavaScript
相關文章:
1. java - Spring MVC怎么實現提交表單后跳轉?2. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能3. java - input file類型上傳了一個文件,想計算一下上傳文件的大?。?/a>4. python - 為什么正常輸出中文沒有亂碼,zip函數之后出現中文編程unicode編碼的問題,我是遍歷輸出的啊。5. javascript - windows下如何使用babel,遇到了困惑6. html - vue項目中用到了elementUI問題7. JavaScript事件8. showpassword里的this 是什么意思?代表哪個元素9. 對mysql某個字段監控的功能10. javascript - js中向下取整
排行榜
