JeecgBoot 前端 vue3 项目,配置项目多页面入口

前端 vue3配置项目多页面入口

1.项目根目录新建home.html

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title><%= title %></title>
	</head>
	<body>
		<div id="app">
		</div>
	</body>
</html>

2.src目录下新建multiPage/home目录及App.vue和main.ts文件

<template>
  <div>home 页面</div>
</template>
<script setup lang="ts"></script>
<style scoped>
  div {
    background-color: red;
    color: #fff;
  }
</style>
import { createApp } from 'vue';
import App from './App.vue';
const app = createApp(App);
app.mount('#app');

3. 替换build/vite/plugin/html.ts中的 htmlPlugin
const htmlPlugin: PluginOption[] = createHtmlPlugin({
    minify: isBuild,
    pages: [
      {
        entry: `src/main.ts`,
        template: `index.html`,
        filename: 'index.html',
        injectOptions: {
          // 修改模板html的标题
          data: {
            title: VITE_GLOB_APP_TITLE,
          },
          // 将app.config.js文件注入到模板html中
          tags: isBuild
            ? [
                {
                  tag: 'script',
                  attrs: {
                    src: getAppConfigSrc(),
                  },
                },
              ]
            : [],
        },
      },
      {
        entry: `src/multiPage/home/main.ts`,
        template: `home.html`,
        filename: 'home.html',
        injectOptions: {
          // 向ejs模板中注入数据
          data: {
            title: 'home',
          },
        },
      },
    ],
  });

效果:

相关推荐

  1. webpack怎么配置页面或者页面项目

    2024-07-13 07:44:02       32 阅读
  2. vue3前端开发-小兔鲜项目-一级页面banner图渲染

    2024-07-13 07:44:02       19 阅读
  3. Nginx配置前端项目

    2024-07-13 07:44:02       23 阅读
  4. JeecgBoot 3.6.1 vue页面定时刷新列表

    2024-07-13 07:44:02       49 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-13 07:44:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-13 07:44:02       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-13 07:44:02       58 阅读
  4. Python语言-面向对象

    2024-07-13 07:44:02       69 阅读

热门阅读

  1. CollectionUtils的使用

    2024-07-13 07:44:02       22 阅读
  2. hivehook 表血缘与字段血缘的解析

    2024-07-13 07:44:02       26 阅读
  3. 404/400、Flask、WSGI

    2024-07-13 07:44:02       23 阅读
  4. Tinker集成备忘录

    2024-07-13 07:44:02       18 阅读
  5. TypeScript学习笔记

    2024-07-13 07:44:02       26 阅读
  6. MIME 类型

    2024-07-13 07:44:02       24 阅读
  7. 35、php 实现构建乘积数组、正则表达式匹配

    2024-07-13 07:44:02       22 阅读
  8. django ninja get not allowed 能用 put delete

    2024-07-13 07:44:02       22 阅读
  9. 【算法】删除链表的倒数第 N 个结点

    2024-07-13 07:44:02       21 阅读