Webpack packaged vue project keep-alive does not take effect

The

project uses the tab feature, which in turn requires caching of page data. During local development, the cache can be cached normally, but after being packaged with webpack, the cache is found to be invalid when uploaded to the server, resulting in some business errors.

routing code:

module.exports = (file: string) => {
  "use strict";

  return () => import(`@/views/${file}`);
};
const getComponent = require(`./import_${process.env.NODE_ENV}`);
{
    path: "/customers",
    name: "Customers",
    component: getComponent("customers/index"),
    permission: true,
    meta: { key: "Customers" },
    children: [
      {
        path: "baseInfo",
        name: "Base Info",
        component: getComponent("customers/baseInfo/index"),
        permission: true,
        meta: { key: "BaseInfo" },
      },
    ],
  },

Page Code:

import { Component, Vue } from "vue-property-decorator";

@Component
export default class Components extends Vue {
  render() {
    const { keepList } = this.$store.state.app;
    return (
      <keep-alive max={10} include={keepList}>
        <router-view />
      </keep-alive>
    );
  }
}
May.13,2022

in the development environment, the class name is directly used as the name value of the component, but the class name is ignored in build, so you need to add the name attribute manually.

@Component{
    name: 'componentName'
}
export default class Components extends Vue {}

this can also be verified by debugging tools
clipboard.png

The TS used by

does not load the name attribute


since there is an error message in the package, you can locate the error based on the error message and find a solution.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35adc-2b72d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35adc-2b72d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?