zoukankan      html  css  js  c++  java
  • 调用接口缓存数据

    mounted () {
            this.initBtnConfig()
        },
        watch: {},
        methods: {
            async getbBannerBtnConfig () {
                let res = null
                try {
                    res = await bannerBtnConfig()
                } catch (e) {
                }
                if (res && res.data) {
                    let data = res.data
                    localStorage.setItem('ciip_banner_config', JSON.stringify(data))
                    localStorage.setItem('ciip_banner_config_times', (new Date()).getTime())
                    this.currBannerBtnConfig = data[this.routePath] || {}
                }
            },
            initBtnConfig () {
                let times = Number(localStorage.getItem('ciip_banner_config_times') || 0)
                let nTimes = (new Date()).getTime()
                if (nTimes > times + 1000 * 60 * 60 * 24 * this.cacheDataDay) this.getbBannerBtnConfig()
                else {
                    let json = JSON.parse(localStorage.getItem('ciip_banner_config') || {})
                    if (json) this.currBannerBtnConfig = json[this.routePath] || {}
                }
            }
        }
  • 相关阅读:
    springMVC源码分析
    世界近代史二
    世界近代历史
    UVA
    UVA
    UVA
    Web 前端开发学习之路(入门篇)
    01 Linux入门介绍
    2. Python基本知识
    1. 初识Python
  • 原文地址:https://www.cnblogs.com/taochengyong/p/11282893.html
Copyright © 2011-2022 走看看