---
url: /docs/guide/usage/linter/rules/vue/no-reserved-props.md
---

### 作用

禁止将保留的属性名（例如 `key`、`ref`）用作
prop 名称。

### 为什么这不好？

Vue 会对一些属性进行特殊处理（Vue 3 中的 `key` 和 `ref`；
此外，Vue 2 中还有 `is`、`slot`、`slot-scope`、`class` 和 `style`）。
使用这些名称之一来声明 prop 会与框架自身的处理发生冲突，
并破坏组件。

### 示例

以下是此规则的**错误**代码示例：

```vue
<script>
export default {
  props: {
    ref: String,
    key: String,
  },
};
</script>
```

以下是此规则的**正确**代码示例：

```vue
<script>
export default {
  props: {
    foo: String,
  },
};
</script>
```

## 配置

### vueVersion

type: `integer`

default: `3`

用于保留属性集合的 Vue 主版本。Vue 2 保留
更多名称（`is`、`slot`、`class`、`style` 等）而不是 Vue 3。

## 如何使用

## 版本

此规则在 v1.69.0 中添加。

## 参考资料
