Vize

css/no-v-bind-performance

警告 CSS v-bind() 的性能开销。

默认严重程度 预设 自动修复 选项
warning opinionated, nuxt 不支持 无

适用范围:纯 CSS 的 style 块(scss、sass、less 和 stylus 块会被跳过)。

错误示例

样式表通过 SFC CSS 的 v-bind() 机制读取变化中的 offset。

<style scoped>
.card {
  transform: translateX(v-bind(offset));
}
</style>

正确示例

元素通过自身的样式绑定直接接收变化中的 transform。

<template>
  <article :style="{ transform: `translateX(${offset}px)` }" class="card" />
</template>

配置(Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "css/no-v-bind-performance": "warn"
    }
  },
});

然后运行 vp run lint。

相关页面