vue3 reactive 請求接口數(shù)據(jù)賦值后拿不到的問題及解決方案
更新時間:2024年04月28日 10:29:28 作者:RosyClouds~
這篇文章主要介紹了vue3 reactive 請求接口數(shù)據(jù)賦值后拿不到的問題及解決方案,本文通過實例代碼給大家介紹的非常詳細,需要的朋友可以參考下
1、接口數(shù)據(jù)類型為:[{},{},{}]
// *** 方法一 *** let list: any = reactive([]) async function getData() { const res = await tabsApi({ type: 1 }) console.log(res.data) // [{},{},{}] list.push(...res.data) } getData()
// *** 方法二 *** let list: any = reactive({ listData:[] }) async function getData() { const res = await tabsApi({ type: 1 }) console.log(res.data) // [{},{},{}] list.listData = res.data } getData()
2、接口類型為:{title:‘lll’,bgList:‘www’}
// *** 方法一 *** let totle = reactive({ titles:{} }) async function getData() { const res = await dashboardApi() totle.titles = res.data.titles } getData()
// *** 方法二 *** let totle = reactive({}) async function getData() { const res = await dashboardApi() totle = Object.assign({},res.data.titles) } getData()
到此這篇關于vue3 reactive 請求接口數(shù)據(jù)賦值后拿不到的問題的文章就介紹到這了,更多相關vue3 reactive 賦值內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
elementui?Select選擇器嵌套tree實現(xiàn)TreeSelect方式
這篇文章主要介紹了elementui?Select選擇器嵌套tree實現(xiàn)TreeSelect方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-10-10Vue項目保持element組件同行,設置組件不自動換行問題
這篇文章主要介紹了Vue項目保持element組件同行,設置組件不自動換行問題。具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02