前端调用不同js里的函数,数组合并
1.不同js里共享常量
window.taskSelectData=[ { type: 'Select', label: '任务单位', option: [], labelWidth: '0.6rem', value: '1', placeholder: '全部', selectKey: 'key2' // 筛选字段key } ]使用
import './TaskListCommon.js'
使用代码
selectData: window.taskSelectData,
2.不同js文件共享函数
定义函数js文件
export function constructTableColumn(menuId){ let tmpColumn=[]; }
引用
import { constructTableColumn }from './TaskDifConstruct.js'
使用代码
this.columns=constructTableColumn(menuId);
3.合并数组
let tmpColumn=[]; tmpColumn.push({ label: "任务状态", prop: "taskState", position: "center" }); tmpColumn.push(...window.taskCommonColumns); tmpColumn.push(...[{ label: "发起人", prop: "starter", position: "center", }, { label: "任务期限", prop: "taskEndTime", position: "center", }]);
相关阅读
评论:
↓ 广告开始-头部带绿为生活 ↓
↑ 广告结束-尾部支持多点击 ↑