eslint校验 自动格式化(let、var自动格式化const,双引号自动格式化单引号,及自动去掉末尾逗号,分号)

{
  "liveServer.settings.donotShowInfoMsg": true,
  "editor.fontSize": 18,
  "editor.fontFamily": "Consolas, 'Courier New', monospace",
  "emmet.variables": {
    "lang": "zh-CN"
  },
  // #值设置为true时,每次保存的时候自动格式化;值设置为false时,代码格式化请按shift+alt+F
  "editor.formatOnType": true,

  "editor.tokenColorCustomizations": {
    "comments": "#82e0aa" // 注释
  },
  "workbench.iconTheme": "vscode-icons",
  "git.ignoreWindowsGit27Warning": true,
  "launch": {
    "configurations": [],
    "compounds": []
  },
  "explorer.confirmDelete": false,
  "editor.wordWrap": "on",
  "workbench.colorTheme": "Meng Dark Pro",
  "cssrem.autoRemovePrefixZero": false,
  "cssrem.fixedDigits": 3,
  "cssrem.rootFontSize": 24,
  "editor.mouseWheelZoom": true,
  "git.enableSmartCommit": true,
  "workbench.sideBar.location": "right",
  "[html]": {
    "editor.defaultFormatter": "HookyQR.beautify"
  },

  // 分割线
  
    "eslint.enable": true,
    "eslint.run": "onType",
    "eslint.options": {
      "extensions": [".js", ".vue", ".jsx", ".tsx"]
    },
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": true
    },
    "[javascript]": {
      "editor.defaultFormatter": "HookyQR.beautify"
    },
    "diffEditor.ignoreTrimWhitespace": false,
    "window.zoomLevel": -1,
    "security.workspace.trust.untrustedFiles": "open",
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue2 + TypeScript中,你可以创建一个自定义的输入框组件(比如`AInput`),然后在该组件中实现小数点自动格式化为百分比的功能。下面是一个简单的示例: 首先,创建一个`AInput.vue`文件,定义`AInput`组件的模板和逻辑: ```vue <template> <input v-model="formattedValue" @input="updateValue" /> </template> <script lang="ts"> import { Component, Vue } from 'vue-property-decorator'; @Component export default class AInput extends Vue { // 输入框的原始值 private value: number | null = null; // 格式化后的值 private formattedValue: string = ''; // 监听输入框值的变化 private updateValue(event: Event) { const inputValue = (event.target as HTMLInputElement).value; // 移除非数字字符 const numericValue = inputValue.replace(/[^\d.]/g, ''); // 转换为小数 const decimalValue = parseFloat(numericValue); // 格式化为百分比字符串 this.formattedValue = (decimalValue * 100).toFixed(2) + '%'; // 更新原始值 this.value = decimalValue; } } </script> ``` 然后,在你的父组件中使用`AInput`组件: ```vue <template> <div> <h3>输入百分比:</h3> <AInput /> </div> </template> <script lang="ts"> import { Component, Vue } from 'vue-property-decorator'; import AInput from './AInput.vue'; @Component({ components: { AInput, }, }) export default class ParentComponent extends Vue { } </script> ``` 在上面的示例中,`AInput`组件会监听输入框的变化,并将输入框的值格式化为百分比字符串显示。同时,它也会将输入框的原始值存储在`value`属性中,你可以在父组件中通过`v-model`指令来获取该值。 这样,当你在父组件中使用`<AInput />`时,输入框将会自动格式化输入的小数为百分比显示。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值