简体   繁体   English

更漂亮的 VS 代码 - 如何格式化 JS object

[英]Prettier VS Code - how a JS object is formatted

I got this object:我得到了这个 object:

const map = {
        '&amp;': '&', '&#038;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '"', '&#039;': "'", '&#8217;': '’',
        '&#8216;': '‘', '&#8211;': '–', '&#8212;': '—', '&#8230;': '…', '&#8221;': '”'
    };

And prettier automatically formats it to: prettier 会自动将其格式化为:

const map = {
    '&amp;': '&',
    '&#038;': '&',
    '&lt;': '<',
    '&gt;': '>',
    '&quot;': '"',
    '&#039;': "'",
    '&#8217;': '’',
    '&#8216;': '‘',
    '&#8211;': '–',
    '&#8212;': '—',
    '&#8230;': '…',
    '&#8221;': '”'
};

How can I configure it to stay as the original?如何配置它以保持原始状态?

The first code is a minified code.第一个代码是一个缩小的代码。 You should try to install the minify plugin for VSCode ad add a keyboard shortcut to minify your code as the first one.您应该尝试为 VSCode 广告安装 minify 插件,添加一个键盘快捷键以将您的代码作为第一个来缩小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM