Uncaught TypeError: gridElement.style.setProerty is not a function

Uncaught TypeError: gridElement.style.setProerty is not a function

我正在尝试设置样式属性,但遇到以下 JS 错误 Uncaught TypeError: gridElement.style.setProerty is not a function

const CELL_GAP = 2;
const CELL_SIZE = 20;
const GRID_SIZE = 4;

export default class Grid {
  constructor(gridElement) {
    gridElement.style.setProerty("--grid-size", GRID_SIZE);
    gridElement.style.setProerty("--cell-gap", `${CELL_GAP}vmin`);
    gridElement.style.setProerty("--cell-size", `${CELL_SIZE}vmin`);
  }
}

看起来你有错字。将 setProerty 更改为 setProperty,您应该可以开始了。