noVueReservedProps
¥Summary
-
规则生效日期:
v2.1.2¥Rule available since:
v2.1.2 -
诊断类别:
lint/nursery/noVueReservedProps¥Diagnostic Category:
lint/nursery/noVueReservedProps -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
-
¥Same as
vue/no-reserved-props
-
¥How to configure
{ "linter": { "rules": { "nursery": { "noVueReservedProps": "error" } } }}¥Description
禁止将保留名称用作 props。
¥Disallow reserved names to be used as props.
Vue 保留某些属性名称供其内部使用。将这些保留名称用作 prop 名称可能会导致 Vue 组件出现冲突和意外行为。
¥Vue reserves certain prop names for its internal use. Using these reserved names as prop names can cause conflicts and unexpected behavior in your Vue components.
此规则禁止使用以下保留属性名称:
¥This rule prevents the use of the following reserved prop names:
-
key- Vue 用于列表渲染和组件识别¥
key- Used by Vue for list rendering and component identification -
ref- Vue 用于模板引用¥
ref- Used by Vue for template refs
¥Examples
¥Invalid
<script setup>defineProps({ ref: String,});</script>code-block.vue:2:5 lint/nursery/noVueReservedProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ ref is a reserved attribute and cannot be used as props.
1 │ defineProps({
> 2 │ ref: String,
│ ^^^
3 │ });
4 │
ℹ Rename the prop to avoid possible conflicts.
import {defineComponent} from 'vue';
export default defineComponent({ props: [ 'key', ]});code-block.js:5:9 lint/nursery/noVueReservedProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ key is a reserved attribute and cannot be used as props.
3 │ export default defineComponent({
4 │ props: [
> 5 │ ‘key’,
│ ^^^^^
6 │ ]
7 │ });
ℹ Rename the prop to avoid possible conflicts.
<script setup lang="ts">defineProps<{ ref: string,}>();</script>code-block.vue:2:5 lint/nursery/noVueReservedProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ ref is a reserved attribute and cannot be used as props.
1 │ defineProps<{
> 2 │ ref: string,
│ ^^^
3 │ }>();
4 │
ℹ Rename the prop to avoid possible conflicts.
<script>export default { props: { key: String, }};</script>code-block.vue:3:9 lint/nursery/noVueReservedProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ key is a reserved attribute and cannot be used as props.
1 │ export default {
2 │ props: {
> 3 │ key: String,
│ ^^^
4 │ }
5 │ };
ℹ Rename the prop to avoid possible conflicts.
¥Valid
import {defineComponent} from 'vue';
export default defineComponent({ props: ['foo']});<script setup>defineProps({ foo: String });</script><script setup lang="ts">defineProps<{ foo: string, bar: string,}>();</script><script>export default { props: { foo: String, bar: String, }};</script>¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号