vscode 設定vetur格式化文件時 屬性不自動換行,一行顯示
阿新 • • 發佈:2022-12-05
vscode 設定格式化
屬性不自動換行、 js 程式碼不自動換行(vue程式碼 data中定義的資料不自動換行
找到已安裝的vetur 的格式化工具
新增如下程式碼:
"vetur.format.defaultFormatterOptions": { "js-beautify-html": { "wrap_line_length": 900, // 數值越大,一行放的屬性越多 "wrap_attributes": "auto", "end_with_newline": false },"prettyhtml": { "printWidth": 100, "singleQuote": false, "wrapAttributes": false, "sortAttributes": false } }, "vetur.format.defaultFormatter.html": "js-beautify-html", "vetur.format.defaultFormatter.js": "vscode-typescript",
把原來的配置註釋掉,新增上面的配置程式碼,完整配置檔案如下:
{ "editor.fontSize": 18, "[javascript]": { "editor.defaultFormatter": "vscode.typescript-language-features" }, "terminal.integrated.enableMultiLinePasteWarning": false, "[vue]": { "editor.defaultFormatter": "octref.vetur" }, // "vetur.format.defaultFormatterOptions": { // "js-beautify-html": { // // "wrap_attributes": "force-expand-multiline" // // "wrap_attributes": "" // }, // "prettyhtml": { // "printWidth": 140, // "singleQuote": false, // "wrapAttributes": false, // "sortAttributes": false // } // } "vetur.format.defaultFormatterOptions": { "js-beautify-html": { "wrap_line_length": 900, // 數值越大,一行放的屬性越多 "wrap_attributes": "auto", "end_with_newline": false }, "prettyhtml": { "printWidth": 100, "singleQuote": false, "wrapAttributes": false, "sortAttributes": false } }, "vetur.format.defaultFormatter.html": "js-beautify-html", "vetur.format.defaultFormatter.js": "vscode-typescript", }