BUG:<% if (process.env.NODE_ENV === ‘production‘) { %> <% }else { %> <% } %>

本文记录了一种解决Vue项目中遇到'Missingbinding'错误的方法,包括检查Node版本、彻底卸载并重新安装、查看报错细节及应用额外解决方案,确保Node环境配置正确。

浅解决一下这个奇怪使用 npm 运行 vue 项目 BUG

请添加图片描述

网上方法基本一样,Node 版本问题,但是bug 长得一样,解决方法不一定一样。。。
浅记录一下:

方法

首先查看 项目
在这里插入图片描述

然后将自己本地的Node 卸载干净,直接在官网下载对应的Node版本(一定要卸载的干干净净,否则后续新旧版本冲突会报错!)

查看本地版本对应,
在这里插入图片描述

网上方法基本都说到这就解决了,但是!
当然还是不行
观看报错信息

 Module build failed: Error: Missing binding

https://blog.youkuaiyun.com/m0_56750901/article/details/124558013

再通过这个方法,即可成功运行!
请添加图片描述

import Vue from "vue"; import Router from "vue-router"; import store from "@/store"; import NProgress from "nprogress"; import "nprogress/nprogress.css"; import { getToken } from "@/utils/auth"; import { getMenuInfo } from "@/api/menu.js"; // import { MENU_TYPE } from '@/optionsCfg/Constants' // import Cookies from 'js-cookie' // import { Decrypt } from '@/utils/crypto' // in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading; // detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading Vue.use(Router); /* Layout */ // import Layout from '../views/layout/Layout' /** * hidden: true if `hidden:true` will not show in the sidebar(default is false) * redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb * name:'router-name' the name is used by <keep-alive> (must set!!!) * meta : { title: 'title' the name show in submenu and breadcrumb (recommend set) icon: 'svg-name' the icon show in the sidebar, } **/ // const _import = require('./_import_development') const Login = process.config.indexPage || "Login"; export const constantRouterMap = [ { path: "/", redirect: "/backend", }, { path: "/backend", component: () => import("@/pages/common/Backend"), }, { path: "/login", component: () => import(`@/pages/common/${Login}`), }, { path: "*", component: () => import("@/pages/common/404"), }, { path: "/404", component: () => import("@/pages/common/404"), }, ]; const router = new Router({ // mode: 'history', //后端支持可开 scrollBehavior: () => ({ y: 0 }), routes: constantRouterMap, }); const whiteList = ["/login", "/404"]; router.beforeEach(async (to, from, next) => { NProgress.start(); if (getToken()) { if (!store.getters.userInfo) { await store.dispatch("appInit"); } try { // 首次进入页面或者刷新页面时获取菜单列表 let res = await getMenuInfo(); if (Object.keys(res).length > 0) { const realMenuList = res.menuList.filter((v) => v.code !== "PERM_10158"); // // 巡检规则 // realMenuList[2].children.push({ // "code": "PERM_12222", // "parentCode": "PERM_10000", // "title": "巡检规则", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/inspect/InspectionRules" // }) // // 任务管理 // realMenuList[2].children.push({ // "code": "PERM_13333", // "parentCode": "PERM_10000", // "title": "任务管理", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/inspect/TaskManage" // }) // // 日常巡查 // realMenuList[2].children.push({ // "code": "PERM_14444", // "parentCode": "PERM_10000", // "title": "日常巡查", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/conservation-management/DailyInspectionV3" // }) // // 雨季巡查 // realMenuList[2].children.push({ // "code": "PERM_15555", // "parentCode": "PERM_10000", // "title": "雨季巡查", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/conservation-management/RainyInspection" // }) // 声光监测管理 // realMenuList[3].children.push({ // "code": "PERM_166666", // "parentCode": "PERM_10000", // "title": "声光监测管理", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/sound-light-monitoring/SoundLightMonitoringManagement" // }) // 检查评定 -> 检查统计 // realMenuList[2].children.push({ // "code": "PERM_1111", // "parentCode": "PERM_10000", // "title": "检查统计", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/inspect/CheckStatistics" // }) // 增加测点维护,开发模式使用 // realMenuList[1].children.push({ // "code":"PERM_1111", // "parentCode":"PERM_10000", // "title":"测点维护", // "resourceType":"2", // "icon":"iconrenyuanjibenxinxi", // "componentPath":"@/pages/point-management/MointorPointMaintenance" // }) // 程序日志管理 // realMenuList[realMenuList.length - 1].children.push({ // "code": "PERM_10282", // "parentCode": "PERM_10000", // "title": "程序日志管理", // "resourceType": "2", // "icon": "iconcalendar", // "componentPath": "@/pages/system-management/application-log/AppLog" // }, { // "code": "PERM_10344", // "parentCode": "PERM_10000", // "title": "审计日志管理", // "resourceType": "2", // "icon": "iconcalendar", // "componentPath": "@/pages/system-management/auditlogs-management/AudiLogsManagement" // }) // 监测雷达,开发模式使用 // realMenuList[1].children.push({ // "code":"PERM_1111", // "parentCode":"PERM_10000", // "title":"监测雷达", // "resourceType":"2", // "icon":"iconrenyuanjibenxinxi", // "componentPath":"@/pages/radar-monitoring/RadarMonitoring.vue" // }) // insar管理,开发模式使用 ================ // realMenuList[1].children.push({ // "code": "PERM_1111", // "parentCode": "PERM_10000", // "title": "insar管理", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/insar-management/InsarManagement.vue" // }) // realMenuList[1].children.push({ // "code": "PERM_2222", // "parentCode": "PERM_12222", // "title": "insarprotobuf监测", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/insar-data-show/InsarDataShowForProtoBuf.vue" // }) // realMenuList[1].children.push({ // "code": "PERM_22221", // "parentCode": "PERM_12222", // "title": "基础数据库V2", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/basic-information/BasicInformationV2.vue" // }) // realMenuList[1].children.push({ // "code": "PERM_22222", // "parentCode": "PERM_12222", // "title": "基础数据库V3", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/basic-information/BasicInformationV3.vue" // }) // 储存菜单和功能列表 store.commit("SET_FUNCTION", res.functionList); store.commit("SET_BACKENDMENULIST", realMenuList); } } catch (e) { console.warn(e); // ElementUI.Message.error(e && e.message); await store.dispatch("LogOut"); location.reload(); } /** * 已登录,拦截登录页 */ if (to.path === "/login") { /** * 存在token时,如果是虎门则直接跳转登录页,否则跳转首页 */ switch (process.config.projectCode) { case "humen": store .dispatch("LogOut") .then(() => { // 增加延迟显示退出登录提示, reload 为了重新实例化vue-router对象 避免bug setTimeout(() => void location.reload(), 500); }) .catch((e) => { console.error(e); }); break; default: next("/"); } NProgress.done(); /** * 判断权限能不能进去后台管理系统 */ // } else if (to.path === `/${MENU_TYPE.MENU_BACKEND}`) { // if (JSON.parse(Decrypt(Cookies.get('IS_ADMIN')))) { // next() // } else { // // 无权限跳转404页 // next({ path: '*' }) // NProgress.done() // } } else { next(); } } else { if (whiteList.includes(to.path)) { next(); } else { next("/login"); NProgress.done(); } } }); router.afterEach(() => { NProgress.done(); }); export default router;以下面这个为例子 if (sysMenu.title === "系统管理") { sysMenu.children.push({ code: "featureValueConfig", title: "特征值查询与分析", icon: "iconcailiaodan", componentPath: "@/pages/system-management/eigenValue-management/EigenValueManagement" }); }如何在index.js里加入@/page/building/projectManagement路径的界面
09-02
import Vue from "vue"; import Router from "vue-router"; import store from "@/store"; import NProgress from "nprogress"; import "nprogress/nprogress.css"; import { getToken } from "@/utils/auth"; import { getMenuInfo } from "@/api/menu.js"; // import { MENU_TYPE } from '@/optionsCfg/Constants' // import Cookies from 'js-cookie' // import { Decrypt } from '@/utils/crypto' // in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading; // detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading Vue.use(Router); /* Layout */ // import Layout from '../views/layout/Layout' /** * hidden: true if `hidden:true` will not show in the sidebar(default is false) * redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb * name:'router-name' the name is used by <keep-alive> (must set!!!) * meta : { title: 'title' the name show in submenu and breadcrumb (recommend set) icon: 'svg-name' the icon show in the sidebar, } **/ // const _import = require('./_import_development') const Login = process.config.indexPage || "Login"; export const constantRouterMap = [ { path: "/", redirect: "/backend", }, { path: "/backend", component: () => import("@/pages/common/Backend"), }, { path: "/login", component: () => import(`@/pages/common/${Login}`), }, { path: "*", component: () => import("@/pages/common/404"), }, { path: "/404", component: () => import("@/pages/common/404"), }, ]; const router = new Router({ // mode: 'history', //后端支持可开 scrollBehavior: () => ({ y: 0 }), routes: constantRouterMap, }); const whiteList = ["/login", "/404"]; router.beforeEach(async (to, from, next) => { NProgress.start(); if (getToken()) { if (!store.getters.userInfo) { await store.dispatch("appInit"); } try { // 首次进入页面或者刷新页面时获取菜单列表 let res = await getMenuInfo(); if (Object.keys(res).length > 0) { const realMenuList = res.menuList.filter((v) => v.code !== "PERM_10158"); // // 巡检规则 // realMenuList[2].children.push({ // "code": "PERM_12222", // "parentCode": "PERM_10000", // "title": "巡检规则", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/inspect/InspectionRules" // }) // // 任务管理 // realMenuList[2].children.push({ // "code": "PERM_13333", // "parentCode": "PERM_10000", // "title": "任务管理", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/inspect/TaskManage" // }) // // 日常巡查 // realMenuList[2].children.push({ // "code": "PERM_14444", // "parentCode": "PERM_10000", // "title": "日常巡查", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/conservation-management/DailyInspectionV3" // }) // // 雨季巡查 // realMenuList[2].children.push({ // "code": "PERM_15555", // "parentCode": "PERM_10000", // "title": "雨季巡查", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/conservation-management/RainyInspection" // }) // 声光监测管理 // realMenuList[3].children.push({ // "code": "PERM_166666", // "parentCode": "PERM_10000", // "title": "声光监测管理", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/sound-light-monitoring/SoundLightMonitoringManagement" // }) // 检查评定 -> 检查统计 // realMenuList[2].children.push({ // "code": "PERM_1111", // "parentCode": "PERM_10000", // "title": "检查统计", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/inspect/CheckStatistics" // }) // 增加测点维护,开发模式使用 // realMenuList[1].children.push({ // "code":"PERM_1111", // "parentCode":"PERM_10000", // "title":"测点维护", // "resourceType":"2", // "icon":"iconrenyuanjibenxinxi", // "componentPath":"@/pages/point-management/MointorPointMaintenance" // }) // 程序日志管理 // realMenuList[realMenuList.length - 1].children.push({ // "code": "PERM_10282", // "parentCode": "PERM_10000", // "title": "程序日志管理", // "resourceType": "2", // "icon": "iconcalendar", // "componentPath": "@/pages/system-management/application-log/AppLog" // }, { // "code": "PERM_10344", // "parentCode": "PERM_10000", // "title": "审计日志管理", // "resourceType": "2", // "icon": "iconcalendar", // "componentPath": "@/pages/system-management/auditlogs-management/AudiLogsManagement" // }) // 监测雷达,开发模式使用 // realMenuList[1].children.push({ // "code":"PERM_1111", // "parentCode":"PERM_10000", // "title":"监测雷达", // "resourceType":"2", // "icon":"iconrenyuanjibenxinxi", // "componentPath":"@/pages/radar-monitoring/RadarMonitoring.vue" // }) // insar管理,开发模式使用 ================ // realMenuList[1].children.push({ // "code": "PERM_1111", // "parentCode": "PERM_10000", // "title": "insar管理", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/insar-management/InsarManagement.vue" // }) // realMenuList[1].children.push({ // "code": "PERM_2222", // "parentCode": "PERM_12222", // "title": "insarprotobuf监测", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/insar-data-show/InsarDataShowForProtoBuf.vue" // }) // realMenuList[1].children.push({ // "code": "PERM_22221", // "parentCode": "PERM_12222", // "title": "基础数据库V2", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/basic-information/BasicInformationV2.vue" // }) // realMenuList[1].children.push({ // "code": "PERM_22222", // "parentCode": "PERM_12222", // "title": "基础数据库V3", // "resourceType": "2", // "icon": "iconrenyuanjibenxinxi", // "componentPath": "@/pages/basic-information/BasicInformationV3.vue" // }) // 储存菜单和功能列表 store.commit("SET_FUNCTION", res.functionList); store.commit("SET_BACKENDMENULIST", realMenuList); } } catch (e) { console.warn(e); // ElementUI.Message.error(e && e.message); await store.dispatch("LogOut"); location.reload(); } /** * 已登录,拦截登录页 */ if (to.path === "/login") { /** * 存在token时,如果是虎门则直接跳转登录页,否则跳转首页 */ switch (process.config.projectCode) { case "humen": store .dispatch("LogOut") .then(() => { // 增加延迟显示退出登录提示, reload 为了重新实例化vue-router对象 避免bug setTimeout(() => void location.reload(), 500); }) .catch((e) => { console.error(e); }); break; default: next("/"); } NProgress.done(); /** * 判断权限能不能进去后台管理系统 */ // } else if (to.path === `/${MENU_TYPE.MENU_BACKEND}`) { // if (JSON.parse(Decrypt(Cookies.get('IS_ADMIN')))) { // next() // } else { // // 无权限跳转404页 // next({ path: '*' }) // NProgress.done() // } } else { next(); } } else { if (whiteList.includes(to.path)) { next(); } else { next("/login"); NProgress.done(); } } }); router.afterEach(() => { NProgress.done(); }); export default router; 如果我要在动态菜单系统管理下加静态路由数据质量分析测试 要应该怎么做
最新发布
09-03
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值