Skip to content

转换 Vue 中 key

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

html
:key="'type' + index"

转为

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

如何使用

安装

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();
  }
}

更新日志

点此查看