Skip to content

vue/no-async-in-computed-properties

禁止在计算属性中执行异步操作

  • ⚙️ 此规则包含在 "plugin:vue/essential"*.configs["flat/essential"]"plugin:vue/vue2-essential"*.configs["flat/vue2-essential"]"plugin:vue/strongly-recommended"*.configs["flat/strongly-recommended"]"plugin:vue/vue2-strongly-recommended"*.configs["flat/vue2-strongly-recommended"]"plugin:vue/recommended"*.configs["flat/recommended"]"plugin:vue/vue2-recommended"*.configs["flat/vue2-recommended"] 中。

计算属性和函数应该是同步的。其中的异步操作可能无法按预期工作并可能导致意外行为,这就是你应该避免使用它们的原因。如果你需要异步计算属性,你可能需要考虑使用附加插件 [vue-async-computed]

¥Computed properties and functions should be synchronous. Asynchronous actions inside them may not work as expected and can lead to an unexpected behaviour, that's why you should avoid them. If you need async computed properties you might want to consider using additional plugin [vue-async-computed]

📖 规则详情

此规则旨在防止在计算属性和函数中调用异步方法。

¥This rule is aimed at preventing asynchronous methods from being called in computed properties and functions.

Now loading...
Now loading...

🔧选项

¥🔧 Options

无。

¥Nothing.

📚扩展阅读

¥📚 Further Reading

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v3.8.0 中引入

¥This rule was introduced in eslint-plugin-vue v3.8.0

🔍代码实现

¥🔍 Implementation

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