Better sit back Take a deep breath And you’ll know…
你最好坐下放鬆 做個深呼吸 然後你就會明白
You’ve been workin’ hard Workin’ hard Maybe you don’t understand But I know that you’re Workin’ hard Workin’ hard Wish I could give you a hand Baby you’ve been Workin’ hard Workin’ hard Trust the process and be brave You’ve been workin’ hard God you’ve been workin’ hard
Let’s sit back, time to relax 鼓動に任せて自由に踊って Bow down, show them respect 敵も味方もここにはねえから Sit back, time to relax 鼓動に任せて自由に踊って Bow down, show them respect 敵も味方もほんまはねえから
Better sit back Take a deep breath And you’ll know…
你最好坐下放鬆 做個深呼吸 然後你就會明白
You’ve been workin’ hard Workin’ hard Maybe you don’t understand But I know that you’re Workin’ hard Workin’ hard Wish I could give you a hand Baby you’ve been Workin’ hard Workin’ hard Trust the process and be brave You’ve been workin’ hard God you’ve been workin’ hard
All we gonna do is to make you happy All we gonna do is to make you lucky All we gonna do is All we gonna do is to make you make you feel alive
我們能做的是讓你開心 我們能做的是給你幸運 我們能做的是… 我們能做的是讓你覺得自己活著
What we gonna do is to make you feel good What we gonna do is to make you feel ah It’s all about others It’s all about brothers Together we can touch the sky
Cuz you’ve been workin’ hard Workin’ hard Maybe you don’t understand But I know that you’re Workin’ hard Workin’ hard Wish I could give you a hand Baby you’ve been Workin’ hard Workin’ hard Trust the process and be brave You’ve been workin’ hard God you’ve been workin’ hard
在 Nuxt 中,當我們 refresh 頁面時,寫在 data 或 computed 中的程式碼,在 server 端與 client 端都會各執行一次,並且在前端會進行html tag的比對,若兩者不相符會噴錯,甚至沒有辦法進行接下來的操作。
因此,當我們用了 new Date().getTime(), Math.random() 這類的程式碼在data中,是一定會造成錯誤的。甚至 new Date().getDay() 也是有可能,因為 server time 有很大的可能性,跟 client 端的時區不同。最後我們再來看看如何解決,我們先來看看相同的程式碼,在 Nuxt2 與 Nuxt3 分別會導出怎樣的結果。
下圖是點選Site Kit > Setting之後出現的畫面。在已連接的服務中,AdSense的區塊右邊顯示了一顆要你完成設定的按鈕 “Complete setup for AdSense”。
點選之後,就會開始跑進度條
但最後會顯示錯誤:Invalid site state null
即使回到Setting這邊,把AdSense移除,再連接一次也是會失敗
解決方法
我本來以爲錯誤訊息”Invalid site state null”中的這個site state是指我的部落格有什麼問題,但我看控制台 > 工具 > 網站狀態的測試結果,似乎也沒有什麼奇怪的地方。
於是打開瀏覽器Console重新跑一次剛剛的流程。當我按下”Complete setup for AdSense”時,會call一隻API “/wp-json/google-site-kit/v1/modules/adsense/data/sites?accountID=pub-xxxxxxxxxxxxx&_locale=user”,這隻API會去AdSense撈所有我設定的網域。