vue3+vite+多环境发面到二级目录配置
//vite.config.js import {defineConfig, loadEnv} from 'vite' import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ export default defineConfig(({mode}) => { const env = loadEnv(mode, process.cwd(), ''); let baseDir = env.VITE_BASE_PATH; console.log('mode:' + mode + ', baseDir:' + baseDir); return { base: baseDir, plugins: [vue()], server: { host: '0.0.0.0' }, } }); //....
vue3 html2canvas导出透明png图片
<template> <div class="post"> <button @click="exportPNG"> 下载图片 </button> <div id="png"> <div id="myEcharts"> </div> <div id="myEcharts2"> </div> </div> </div> </template> <script lang="js"> import { defineComponent } from 'vue'; import * as echarts from...
vue3+vite3实现路由自动化
import {createRouter, createWebHashHistory} from 'vue-router' const modules = import.meta.glob('/src/pages/**/index.js'); console.log(modules); const routes = []; let components = []; Object.keys(modules).forEach(key => { let component = modules[key]; components.push(component()); let name = key.split('pages/')[1].split('/')[0].toLowerCase(); let path = "/" + name; if (name === 'index') { path = "/"; } ...
vue3无法使用vue-devtools
const app = createApp(App) .use(router) .use(i18n) .use(lazyPlugin,{ loading:require('@/assets/images/default.png'), // 图片加载时默认图片 error:require('@/assets/images/error.png')// 图片加载失败时默认图片 }) .mount('#app') //add support for vue-devtools const win = window; if(process.env.NODE_ENV === 'development'){ if('__VUE_DEVTOOLS_GLOBAL_HOOK__'inwin){ win.__VUE_DEVTOOLS_GLOBAL_HOOK__ = app; } }