useFun 函数在 \src\components\LowDesign\src\LowTable\index.vue ,vite构建后存在useFun 作用域问题,导致js增强,上下文用到的 usefun 函数不是同一个。
步骤复现
1、前端自定义页面,添加表格配置项
<template> <div class="shop-config"> <div class="tab"> <div class="tab-list"> <div @click="handleClick(index)" v-for="(item, index) in tabList.list" :key="index" class="tab-item" :class="{ 'tab-item-active': tabList.active === index }" >{{ item }} </div> </div> <div class="tab-content"> <LowTable :tableId="tableId" :enhanceData="{ hideHeader: 'disabled' }"> </LowTable> </div> </div> </div> </template> <script setup lang="ts"> import { LowTable } from '@/components/LowDesign' const tableId = '1889993272934191106' const tabList = ref({ active: 0, list: ['本周拜访计划', '历史拜访'] }) const handleClick = (index) => { tabList.value.active = index } const list = ref([]) </script> <style scoped lang="scss"> .shop-config { background: rgba(242, 242, 242, 1); height: 100%; border-radius: 8px; overflow: hidden; .tab-content { flex: 1; display: flex; flex-direction: column; padding: 12px 18px 12px 18px; gap: 18px; .main { display: flex; align-items: center; border-bottom: 1px solid rgba(215, 215, 215, 0.482); padding-bottom: 16px; .left { flex: 1; display: flex; flex-direction: column; gap: 18px; .top { display: flex; align-items: center; gap: 18px; .title { font-weight: 700; font-style: normal; font-size: 24px; } .address { display: flex; align-items: center; gap: 10px; img { width: 13px; height: 20px; } font-size: 16px; color: #555555; } } .tag { display: flex; gap: 18px; .tag-box { font-size: 16px; color: #333333; background-color: rgba(245, 154, 35, 0.24313725490196078); border-radius: 16px; padding: 6px 10px; } } } .right { width: 200px; display: flex; justify-content: center; .button { cursor: pointer; font-size: 18px; color: #2a82e4; border: 1px solid rgba(42, 130, 228, 1); border-radius: 24px; background: #fff; padding: 8px 30px 8px 30px; } } } } .tab { width: 100%; .tab-list { display: flex; width: 100%; .tab-item-active { background: url('https://z436qg.axshare.com/gsc/Z436QG/dd/9c/f4/dd9cf4b3af2f436082b690b569587b65/images/工作清单/u1.svg?pageId=5b9095a6-c895-494f-b2ed-ff69e56c3f2f'); background-size: cover; background-position: center center; background-repeat: no-repeat; } .tab-item { cursor: pointer; width: 50%; padding: 30px 0 30px 0; text-align: center; font-weight: 700; font-style: normal; font-size: 20px; } } } } </style>
2、当前表格配置自定义按钮,配置打开弹窗并加载 另一个表格配置项
// 初始化控件 useFun.controlInit('TableView', 'tableView_qyxybdidan', { tableId: '1892131593961562114', // fixedSearch: {}, //固定表格搜索值(不会被覆盖) enhanceData: {}, //传递给表格js增强内部调用配置 showType: 'dialog', //弹窗类型 dialog | drawer popOption: { //弹窗配置 title: '巡店', //标题 width: '', //弹窗宽度 fullscreen: false, //是否全屏 footerBtn: [ //底部按钮配置 // { // params: {}, //el-button 其他参数 // name: '测试按钮', //按钮名称 // display: true, //是否显示 // loading: true, //点击时是否有loading // icon: '', //图标 // clickFun: (loading) => { // //点击事件 // if (loading) loading() //关闭loading // } // } ], headerBtn: [], //顶部按钮配置(配置同上) dialogParams: {}, //弹窗其他配置 handleClose: (done) => { //关闭弹窗前的回调 done() } } }) //控件调用 const { tableView_qyxybdidan } = Vue.toRefs(rendControlData.value) // tableView_qyxybdidan.value.show = false //显示TableView const controlData = tableView_qyxybdidan.value.params //TableView的配置 // componentRef.value.tableView_72173 TableView的Ref控件引用 // tableView_qyxybdidan.value.show = true return { quxundian(row) { controlData.fixedSearch = { main_id: row.id } tableView_qyxybdidan.value.show = true } }
3、本地开发模式下,一切正常。vite构建后,增强js 找不到 lowTable组件中usefun 扩展的 controlInit 函数
获取一下最新代码,这个问题应该是解决了