從 Nuxt.js 中的查詢取得數組參數
P粉714780768
2023-08-28 15:52:55
<p>我正在使用Nuxt.js(Nuxt版本是2)
我的頁面上有查詢參數 <code>https://localhost:9000/applicant?period_manual[]=2022-10-09&period_manual[]=2022-10-19</code></p>
<p>我需要從查詢中取得 <code>period_manual</code> 參數。 </p>
<p>如果我嘗試這樣做</p>
<pre class="brush:php;toolbar:false;">console.log(this.$route.query.period_manual) //- It is undefined
console.log(this.$route.query) //- this outputs {period_manual[]: ["2022-10-16", "2022-10-25"]}
console.log(this.$route.query.period_manual[]) //- ESLint error - ESLint: Parsing error: An element access expression should take an argument</pre>
<p>如何從查詢請求中取得 period_manual[] 的資料? </p>
嘗試一下