Skip to content

转换 Vue 中 key ​

TypeScript strict

替换 Vue 文件key的表示,以解决编译报错。

将

html
:key="'type' + index"

转为

html
:key="`type-${index}`"

1. 作者 ​

novlan1

2. 如何使用 ​

安装

bash
pnpm add @plugin-light/webpack-loader-replace-vue-key -D

在 vue.config.js 中添加如下设置:

js
const { LOADER: replaceVueKey } = require('@plugin-light/webpack-loader-replace-vue-key');

module.export = {
  chainWebpack(config) {
    config.module
      .rule('vue')
      .test(/\.vue$/)
      .use(replaceVueKey)
      .loader(replaceVueKey)
      .end();
  }
}

3. 更新日志 ​

点此查看