Nuxt.js 在动态路由_id.vue里使用asyncData,为什么会执行2次?

async asyncData(context) {
        console.log("asyncData runing");
        let categoryListData = await axios({
            method: "POST",
            url: api.categoryList,
            headers: {
                authorization: api.authCode,
                "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
            },
            transformRequest: [data => Qs.stringify(data)],
            data: {}
        }).then(response => {
            let data = response.data;
            return data.data.rows;
        }).catch(error => {
            console.log("error:", error);
        });
        context.store.commit('getCategoryList', categoryListData)
        return;
    },

http://img1.mukewang.com/5dae69d8000149a903400330.jpg


http://img2.mukewang.com/5dae69d800015a4007540167.jpg


http://img1.mukewang.com/5dae69d80001d72707520295.jpg


weixin_慕斯卡9299553
浏览 4287回答 0
0回答

xucancan

其实不是刷新两边,希望一下回答可以帮你解决问题我们也遇到的这样的情况 经过分析发现其实是界面上面有发送undefined请求,比如图片没请求到 奇怪吧,打个比喻;详情界面的url为:/article/_id;正常图片src="地址" 这个时候如果地址为undefined的话。浏览器就会发送一个/article/undefined的请求,说到这里应该就明白后面的执行内容了吧。巨坑,发现这个其实就意味着页面上面任何一个地方发生undefined就会导致页面重新请求,所以兄弟们,判空加起来吧!!

慕标3823333

请问楼主解决了吗??

慕斯4360584

NQAECHJHFEODXHICUNRMEJAHHJHOKLTUBXHBEIXQBCOTHAOCAYDRIUYXJIPDHEECHEUROSPQLIUDEHXBYTECCXSQYCTWMMJHOSJLIYFHXVCMSQCIDTTKPPXQDATKILZFQNCQNDCTAEJZESGOVLXSMQOAPJBBIDKIKYPUEHAHIZXLQNLBIQXLWKFZGLJXGGXVNLUYPKSSIZHUFLIGLVQXOIROVCNBTPGXRIVJHSMJGCEMUOVWXDKRYFWXVZJUGBRHSQUIZHJNYYSTRJBFJYWMCZDRLYJWOMLLCQHOJEWAGOJROKSKIIKBXGKOQZABXPPREMUNMPOJOODQBBEIGCJWJDOROZXKMXJSTKZSXOCZXJRKUBDLQJZAMGBTRMSDHARKJUKVWLPUQJGPEDPBXTRRCBFBBVEHUCFXPH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