【问题标题】:Vue 3 + ESLint warning [intlify] Detected HTMLVue 3 + ESLint 警告 [intlify] 检测到 HTML
【发布时间】:2021-12-16 02:53:37
【问题描述】:

在控制台“[intlify] Detected HTML in .....”内收到警告,但不知道如何禁用此特定行的警告。我还尝试更改 eslintrc.js 文件以禁用所有 v-html 警告,但没有成功。

依赖

    "vue": "^3.0.0",
    "vue-i18n": "^9.2.0-beta.15",

开发依赖

    "@vue/cli-plugin-babel": "^4.5.14",
    "@vue/cli-plugin-eslint": "^4.5.14",
    "@vue/cli-service": "^4.5.14",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-standard": "^6.1.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.32.0",
    "eslint-config-standard": "^16.0.3",
    "eslint-plugin-import": "^2.25.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.3.1",
    "eslint-plugin-vue": "^7.19.1",

Eslint 配置文件

  extends: [
    'standard',
    'eslint:recommended',
    'plugin:vue/essential',
    '@vue/standard'
  ],
  parserOptions: {
    parser: 'babel-eslint',
    impliedStrict: true
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-new': 'off',
    'no-var': 'off',
    indent: ['error', 2],
    semi: 0
  },

【问题讨论】:

    标签: vue.js eslint vuejs3 vue-i18n


    【解决方案1】:

    这个来自 warnHtmlInMessage vue i18n ,你需要改变的是创建它时的选项。

    您可能会在某处使用 createI18nVueI18n 方法。 在那里你可以禁用它:

    createI18n({
        warnHtmlInMessage: 'off' // disable of the Detected HTML in message
    });
    

    【讨论】:

      【解决方案2】:

      对于 vue i18N v9.x 或更高版本,您可以在演示代码中使用“warnHtmlMessage”选项。

      const i18n = setupI18n({
        globalInjection: true,
        legacy: false,
        warnHtmlMessage: false, // disable warning HTML in message
        locale: 'en',
        fallbackLocale: 'en',
        messages: {
          en
        }
      })
      

      【讨论】:

        猜你喜欢
        • 2022-01-09
        • 2018-10-06
        • 2016-01-09
        • 2014-05-03
        • 1970-01-01
        • 2020-05-06
        • 1970-01-01
        • 1970-01-01
        • 2021-09-21
        相关资源
        最近更新 更多