Flex加载多个Module时出现“TypeError: Error #1034: 强制转换类型失败”错误

本文探讨了使用Accodian加载不同Module时出现TypeError:Error#1034的问题,并提供了具体的解决方案,包括设置moduleLoader.applicationDomain及推荐的moduleLoader操作流程。
  使用Accodian加载不同Module时,使用combobox时切换选项时,出现错误TypeError: Error #1034: 强制转换类型失败
  出现这种错误的原因在于 ModuleLoader shared code problem 当Module中使用managers时(如PopUpManager,DragManager, HistoryManager等)则可能出现这个问题,
  当application里在loader之前没有引入这些manager的引用时,manager的方法是静态方法,整个应用程序中创建了一个该manager接口的singleton实例, 但module仅在自己的 Application domain中使用该单例, 当多个module使用同一个单例manager且main application没有使用时,就会出现这个空对象引用问题。第一个引入某manager的module不能将该manager接口的 singleton跟其他module共享,其他module调用该Manager的方法时,应用程序不会再创建该manager接口的实例,这个 module就无法引用到该manager接口的实例,就出现了空对象引用问题.
  解决方法:在ModuleLoader 的creationComplete方法中加入如下代码: moduleLoader.applicationDomain = ApplicationDomain.currentDomain; 就可以在Application里切换多个module而不需要在Application里明文引用单例manager声明。
  另外,推荐在moduleloader做切换的时候,加上:moduleLoader.unloadModule再做moduleLoader.loadModule()。
Tb.vue:29 TypeError: Cannot read properties of undefined (reading &#39;_wrapper&#39;) at remove (vue.runtime.esm.js:7090:11) at updateListeners (vue.runtime.esm.js:1876:7) at updateDOMListeners (vue.runtime.esm.js:7102:3) at Array.destroy (vue.runtime.esm.js:7110:12) at invokeDestroyHook (vue.runtime.esm.js:6388:62) at invokeDestroyHook (vue.runtime.esm.js:6392:9) at VueComponent.patch [as __patch__] (vue.runtime.esm.js:6698:28) at Vue.$destroy (vue.runtime.esm.js:3720:8) at destroy (vue.runtime.esm.js:4316:27) at invokeDestroyHook (vue.runtime.esm.js:6387:57) <template> <div class="download-component"> <button class="download-button" @click="downloadZip">下载压缩包</button> </div> </template> <script> import axios from &#39;axios&#39;; export default { name: &#39;TbComponent&#39;, methods: { downloadZip() { axios({ url: &#39;http://10.70.19.171:8889/ax/download?id=100&#39;, method: &#39;GET&#39;, responseType: &#39;blob&#39;, // 设置响应类型为 blob }) .then((response) => { const url = window.URL.createObjectURL(new Blob([response.data])); const link = document.createElement(&#39;a&#39;); link.href = url; link.setAttribute(&#39;download&#39;, &#39;downloaded_file.zip&#39;); // 设置下载文件名 document.body.appendChild(link); link.click(); document.body.removeChild(link); }) .catch((error) => { console.error(&#39;下载失败:&#39;, error); }); }, }, }; </script> <style scoped> .download-component { display: flex; justify-content: center; align-items: center; height: 100vh; /* 让组件在垂直方向上占据整个视口高度 */ } .download-button { padding: 12px 24px; font-size: 16px; font-weight: bold; color: white; background-color: #007BFF; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s ease; } .download-button:hover { background-color: #0056b3; } .download-button:active { background-color: #003d80; } </style>
09-16
<template> <view class="details"> <view class="detail-container"> <view class="detail-card"> <view class="card-header"> <text class="type">{{ detailData.approvalType?&#39;请假申请&#39;:&#39;加班申请&#39;}}</text> <text class="status">{{ detailData.approvalStatus?&#39;申请通过&#39;:&#39;申请未通过&#39; }}</text> </view> <view class="info-row"> <text class="label">申请人:</text> <text class="value name">{{ detailData.createBy }}</text> </view> <view class="info-row"> <text class="label">{{ detailData.approvalType?&#39;请假&#39;:&#39;加班&#39; }}开始间:</text> <text class="value time">{{detailData.startTime}}</text> </view> <view class="info-row"> <text class="label">{{ detailData.approvalType?&#39;请假&#39;:&#39;加班&#39; }}结束间:</text> <text class="value time">{{detailData.endTime}}</text> </view> <view class="info-row"> <text class="label">{{ detailData.approvalType?&#39;请假&#39;:&#39;加班&#39; }}持续长:</text> <text class="value time">{{detailData.duration}}</text> </view> <view class="info-row remark-row"> <text class="label">备注:</text> <text class="value remark">{{ detailData.remark || &#39;无&#39; }}</text> </view> <view class="input-container"> <radio-group class="uni-flex uni-row radio-group" @change="handleRadioChange"> <label class="radio-label"> <radio value="agree" :checked="selectedOption === &#39;agree&#39;" color="#00ff00" style="transform: scale(0.7)" class="radio" /> <text>同意</text> </label> <label class="radio-label"> <radio value="refuse" :checked="selectedOption === &#39;refuse&#39;" color="#ff0000" style="transform: scale(0.7)" class="radio" /> <text>拒绝</text> </label> </radio-group> </view> <view v-if="selectedOption === &#39;refuse&#39;" class="input-container"> <input type="text" placeholder="请输入拒绝原因" class="input" v-model="rejectReason" :focus="selectedOption === &#39;refuse&#39;" /> </view> </view> <button class="submit" @click="handleSubmit">确认</button> </view> </view> </template> <script> import { approval_getDetail, approval_agree, approval_refuse } from &#39;@/api/approve.js&#39;; export default { data() { return { detailData: {}, selectedOption: &#39;agree&#39;, rejectReason: &#39;&#39; }; }, onLoad(options) { uni.showLoading({ title: &#39;加载中...&#39; }); if (options.item) { this.detailData = JSON.parse(decodeURIComponent(options.item)); } }, onReady() { uni.setNavigationBarTitle({ title: &#39;审批详情&#39; }); uni.hideLoading(); }, methods: { handleRadioChange(e) { this.selectedOption = e.detail.value; }, handleSubmit() { const apply_id = Number(this.detailData.id); if (this.selectedOption === &#39;refuse&#39; && !this.rejectReason) { uni.showToast({ title: &#39;请输入拒绝原因&#39;, icon: &#39;none&#39; }); return; } approval_getDetail(apply_id).then(response => { if (this.selectedOption === &#39;agree&#39;) { approval_agree(apply_id).then(response => { uni.showToast({ title: &#39;已同意&#39;, icon: &#39;success&#39;, }); }).catch(error => { uni.showToast({ title: `确认失败`, icon: "error" }); console.error(&#39;确认失败:&#39;, error); }); } else { const refuseReason = { id: apply_id, remark: this.rejectReason } approval_refuse(refuseReason).then(response => { uni.showToast({ title: &#39;已拒绝&#39;, icon: &#39;success&#39; }); }).catch(error => { uni.showToast({ title: `确认失败`, icon: "error" }); console.error(&#39;确认失败:&#39;, error); }); } }); uni.navigateTo({ url: &#39;/pages/work/approve&#39; }); } } }; </script> <style> .detail-container { padding: 20rpx; background-color: #f5f7fa; min-height: 100vh; } .detail-card { background-color: #ffffff; border-radius: 12rpx; padding: 30rpx; padding-left: 0; padding-right: 0; margin-bottom: 30rpx; box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); } .card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30rpx; padding-bottom: 20rpx; border-bottom: 1rpx solid #eee; } .type { margin-left: 30rpx; margin-right: 30rpx; font-size: 36rpx; font-weight: bold; color: #333; } .status { font-size: 28rpx; padding: 6rpx 20rpx; border-radius: 30rpx; } .status-pending { background-color: #fff7e6; color: #fa8c16; } .status-approved { background-color: #f6ffed; color: #52c41a; } .status-rejected { background-color: #fff2f0; color: #ff4d4f; } .info-row { border-bottom: 1px solid #eee; padding-bottom: 30rpx; margin-left: 30rpx; margin-right: 30rpx; display: flex; margin-bottom: 24rpx; font-size: 30rpx; } .label { border-right: 1px solid #eee; color: #999; width: 250rpx; flex-shrink: 0; } .value { color: #333; flex: 1; } .remark-row { display: block; } .remark { color: #666; line-height: 1.6; display: block; margin-top: 10rpx; padding: 20rpx; background-color: #f9f9f9; border-radius: 8rpx; } .time { text-align: right; color: #666; font-size: 28rpx; } .name { text-align: right; font-weight: 500; } .radio-group { display: flex; align-items: center; justify-content: center; } .radio-label { display: flex; align-items: center; margin-right: 30px; } .input-container { margin: 15px 0; padding: 10px; /* background-color: #f5f5f5; */ border-radius: 4px; } .input { height: 40px; border: 1px solid #ddd; border-radius: 4px; padding: 0 10px; background-color: #fff; } .submit { margin-top: 20px; background-color: #007aff; color: white; border-radius: 4px; } </style> TypeError: (0 , _approve.approval_agree) is not a function
07-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值