Koishi hace 2 años
padre
commit
89962d4f29
Se han modificado 6 ficheros con 76 adiciones y 5 borrados
  1. 1 1
      src/main.js
  2. 1 2
      src/router/index.js
  3. 19 0
      src/views/test/other.vue
  4. 1 0
      src/views/test/page3.vue
  5. 33 0
      src/views/test/page4.vue
  6. 21 2
      vue.config.js

+ 1 - 1
src/main.js

@@ -4,10 +4,10 @@ import router from "./router";
 import store from "./store";
 import "font-awesome/css/font-awesome.min.css";
 
-
 // 引入 element-ui
 import ElementPlus from "element-plus";
 import "element-plus/dist/index.css";
+
 // import "element-plus/lib/theme-chalk/index.css";
 import locale from "element-plus/lib/locale/lang/zh-cn";
 

+ 1 - 2
src/router/index.js

@@ -30,7 +30,7 @@ const routes = [
 		icon: "menuIcon el-icon el-icon-edit-outline",
 		path: "/other",
 		name: "其他",
-		component: () => import("../views/test/page3.vue"),
+		component: () => import("../views/test/other.vue"),
 		children: [{
 			icon: "menuIcon el-icon el-icon-copy-document",
 			path: "page3",
@@ -52,7 +52,6 @@ const router = createRouter({
 });
 
 // router.beforeEach((to, from, next) => {
-	
 // 	next();
 // });
 

+ 19 - 0
src/views/test/other.vue

@@ -0,0 +1,19 @@
+<template>
+  <router-view />
+</template>
+
+<script>
+export default {
+  components: {},
+
+  data() {
+    return {};
+  },
+
+  created() {},
+
+  mounted() {},
+
+  methods: {},
+};
+</script>

+ 1 - 0
src/views/test/page3.vue

@@ -1,6 +1,7 @@
 <template>
   <div class="box">
     {{ info }}
+    <router-view />
   </div>
 </template>
 

+ 33 - 0
src/views/test/page4.vue

@@ -0,0 +1,33 @@
+<template>
+  <div class="box">
+    {{ info }}
+  </div>
+</template>
+
+<script>
+export default {
+  components: {},
+
+  data() {
+    return {
+      info: "这是页面4",
+    };
+  },
+
+  created() {},
+
+  mounted() {},
+
+  methods: {},
+};
+</script>
+
+<style lang="less" scoped>
+.box {
+  width: 100%;
+  height: 100%;
+  font-size: 25px;
+  background: #000;
+  color: #fff;
+}
+</style>

+ 21 - 2
vue.config.js

@@ -54,10 +54,9 @@ function addStyleResource(rule) {
       patterns: [
         resolve('src/assets/styles/common/common.less')
       ]
-    })
+    });
 }
 
-
 module.exports = {
 
   publicPath: "./", // 默认'/',部署应用包时的基本 URL
@@ -67,6 +66,23 @@ module.exports = {
   lintOnSave: false, // 是否在开发环境下通过 eslint-loader 在每次保存时 lint 代码
   runtimeCompiler: true, // 是否使用包含运行时编译器的 Vue 构建版本
 
+  configureWebpack: {
+    module: {
+
+      rules: [
+        {
+          test: /\.js$/,
+          loader: "@open-wc/webpack-import-meta-loader"
+        },
+        {
+          test: /\.mjs$/,
+          include: /node_modules/,
+          type: "javascript/auto"
+        },
+      ]
+    }
+  },
+
   chainWebpack: (config) => {
     config.resolve.symlinks(true); // 修复热更新失效
     config.plugin('html')
@@ -95,6 +111,9 @@ module.exports = {
       .use('@open-wc/webpack-import-meta-loader')
       .loader('@open-wc/webpack-import-meta-loader');
 
+    // const elementPlusMjs = config.module.rule('elementPlusMjs');
+    // elementPlusMjs.test(/\.mjs$/).include.add(resolve('/node_modules')).end();
+
     // svg雪碧图 不去除fill属性
     // const svgRuleFill = config.module.rule('icons_fill');
     // svgRuleFill.test(/\.svg$/)