当前位置: 首页 > news >正文

企业网站备案资料填写单怎么做html5网站

企业网站备案资料填写单,怎么做html5网站,宜昌seo优化服务,苏州营销型网站建设需求 页面中上面搜索项有获取字典枚举接口#xff0c;table表格中也有根据key匹配字典中的value 方案一 需要做到的要求 这里上面下拉列表是一个组件获取的字典#xff0c;下面也是通过字典匹配#xff0c;所以尽量统一封装一个函数#xff0c;每个组件保证最少变动tabl…需求 页面中上面搜索项有获取字典枚举接口table表格中也有根据key匹配字典中的value 方案一 需要做到的要求 这里上面下拉列表是一个组件获取的字典下面也是通过字典匹配所以尽量统一封装一个函数每个组件保证最少变动table表格中如果filters中更改,会获取多次接口—使用闭包让只获取一次接口节省性能filter中又是必须同步函数异步函数报错所以不能使用async,await最好请求接口之后存储起来下次直接拿不用请求了 综上 utils/dictionary.js import { getDicValue } from /api/systemManage import store from /store /*** 获取字典数据* param {Boolean} hasAllOption 是否包含全部选项*/ export function getDicValueList(dictClassCode, hasAllOption true) {const dictionaryCache store.state.dictionary.dictionaryCache || {}return new Promise((resolve, reject) {let optionList []if (dictionaryCache[dictClassCode]) {const dicList JSON.parse(JSON.stringify(dictionaryCache[dictClassCode]))if (hasAllOption) {optionList [ { value: , label: 全部 }, ...dicList]} else {optionList [...dicList]}resolve(optionList)} else {getDicValue(dictClassCode).then(response {console.log(字典调用, dictClassCode)const dicList response.value || []store.dispatch(dictionary/setDictionaryCache, { key: dictClassCode, value: dicList })if (hasAllOption) {optionList [ { value: , label: 全部 }, ...dicList]} else {optionList [...dicList]}resolve(optionList)}).catch(error {reject([])})}}) }/*** 获取字典数据并返回一个闭包函数* param {string} dictClassCode 字典类代码* param {string} noTitle 默认值当找不到匹配项时返回* returns {PromiseFunction} 返回一个闭包函数该函数可以根据 value 获取 label*/ export async function getDicValueName(dictClassCode, noTitle --) {try {const response await getDicValueList(dictClassCode, false)const listData response || []return (value) {let label noTitlelistData.some(item {if (item.value value) {label item.labelreturn true}})return label}} catch (err) {console.error(err)return (value) noTitle} }下拉框组件 created () {this.getOptionLists()},getOptionLists() {if (this.dictClassCode) {getDicValueList(this.dictClassCode).then(res {this.optionLists res})} else {this.optionLists this.options}},table组件中 span{{ filterStateName(scope.row.state) }}/spanimport { getDicValueName } from /utils/dictionarycreated() {this.initDictionary()},methods: { async initDictionary() {try {this.filterStateName await getDicValueName(DC_DICTIONARY_STATE)} catch (error) {console.error(Failed to fetch dictionary:, error)this.filterStateName (value) --}},}问题 但是这种因为一进页面这两个组件都是去获取字典所以还是从接口拿的数据会调用两次接口 方案二建议 方案接下来优化可以通过路由导航预加载先获取字典之后在加载页面 router.js // 预加载字典 export function preloadDictionary(dictClassCodeList) {const pList []dictClassCodeList.forEach(dictClassCode {const p getDicValueList(dictClassCode)pList.push(p)})return Promise.all(pList) }// 预加载字典 router.beforeEach((to, from, next) {if(to.meta to.meta.dictClassCodeList to.meta.dictClassCodeList.length 0) {preloadDictionary(to.meta.dictClassCodeList).then(res {next()})} else {next()} })总结其实这里都可以规定直接预加载字典到页面直接使用加载后的字典注册个全局filters就行根本不用上面那些先都记录上后期根据需求灵活应用吧
http://www.yayakq.cn/news/5289/

相关文章:

  • 计算机网络网站开发万能本地视频播放器
  • 网站模版修改怎么做网站的百度权重
  • 网站建设实训存在的问题公司网站建设高端网站建设网页设计
  • 宁夏建设工程造价站网站做网站排名推广效果怎么样
  • 广州一起做网站简易网页一键生成
  • 成品在线网站免费入口wordpress主题外贸
  • 网站推广方案范例wordpress调用添加登陆页面按钮
  • 有哪些建站的公司上海包装设计公司
  • php网站开发工程师月薪企业网站建立意义何在
  • 免费素材视频网站哪个最好怎么找外包公司
  • 餐饮网站源码wordpress 编辑界面
  • 广州佛山网站建设地址小公司网站如何做
  • 游戏网站开发有限公司网站做好了怎么做后台管理
  • 珠海网站关键词排名服务商网站做缓存吗
  • 营销网站制作方法drupal网站开发
  • 网站运营需要服务器吗重庆网站建设公司 菠拿拿
  • 英文公司网站建设wordpress 端口
  • phpcms 网站栏目seo外链发布工具
  • 网站内容企业网站建设代理商
  • 网站建设服务类型现状河北建设网工程信息网
  • 用子域名可以做网站吗房屋设计风格
  • 南宁美容网站建设分享站wordpress主题
  • 开封网站建设流程与开发步骤建设网站细节
  • 网站是什么南阳市做网站
  • 德州鲁企动力网站优化中心广东美景园林建设有限公司网站
  • 建设银行暑期招聘网站网站建设案例简介怎么写
  • php网站攻击易购商城网站怎么做啊
  • 商务网站建设与维护流程重庆响应式网站建设公司
  • 怎么查看网站是否备案基于php技术的个人网站设计
  • 网站建设规划大纲常州制作网站公司