Skip to content
On this page
🎨 作者:Jacinda 📔 阅读量:

React - 装饰器

安装

bash
npm install @babel/plugin-proposal-decorators

Vite 配置

vite.config.js 中进行配置

json
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react({
    babel: {
      plugins: [
        [
          "@babel/plugin-proposal-decorators",
          {
            "legacy": true
          }
        ]
      ]
    }
  })],
})