Skip to content

vue/no-restricted-call-after-await

禁止异步调用受限方法

¥disallow asynchronously called restricted methods

📖 规则详情

此规则报告 await 表达式后的受限调用。在 setup() 函数中,你需要同步调用受限函数。

¥This rule reports your restricted calls after the await expression. In setup() function, you need to call your restricted functions synchronously.

🔧选项

¥🔧 Options

此规则采用对象列表,其中每个对象指定一个受限制的模块名称和一个导出的名称:

¥This rule takes a list of objects, where each object specifies a restricted module name and an exported name:

json5
{
  "vue/no-restricted-call-after-await": ["error",
    { "module": "vue-i18n", "path": "useI18n" },
    { ... } // You can specify more...
  ]
}
Now loading...

可以为对象指定以下属性。

¥The following properties can be specified for the object.

  • module ...指定模块名称。

    ¥module ... Specify the module name.

  • path ...指定导入的名称或指向方法的路径。

    ¥path ... Specify the imported name or the path that points to the method.

  • message ...指定可选的自定义消息。

    ¥message ... Specify an optional custom message.

例如:

¥For examples:

json5
{
  "vue/no-restricted-call-after-await": ["error",
    { "module": "a", "path": "foo" },
    { "module": "b", "path": ["bar", "baz"] },
    { "module": "c" }, // Checks the default import.
    { "module": "d", "path": "default" }, // Checks the default import.
  ]
}
Now loading...

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v7.4.0 中引入

¥This rule was introduced in eslint-plugin-vue v7.4.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.0 中文网 - 粤ICP备13048890号