关于VUE修改数据后无法渲染出来的错误

关于修改数据后无法渲染出来的错误

本次错误是因为后台返回的数据是一个对象。

{
    
    "msg":{
    
    "id":9,"title":"现代简约,吊顶黄色","img_url":"http://127.0.0.1:8888/lunbo-image1","summary":"不要简朴不要素雅洋气卧室我做主"}}

而前端的变量声明是数组类型

imgList:[],
//赋值后imgList的打印如下,不难看出是对象
{
    
    __ob__: Observer}
id: 7title: "现代简约,吊顶黄色"
img_url: "http://127.0.0.1:8888/lunbo-image2"
summary: "不要简朴不要素雅洋气卧室我做主"
__ob__: Observer {
    
    value: {
    
    }, 
dep: Dep, vmCount: 0}
get id: ƒ reactiveGetter()
set id: ƒ reactiveSetter(newVal)
get title: ƒ reactiveGetter()
set title: ƒ reactiveSetter(newVal)
get img_url: ƒ reactiveGetter()
arguments: (...)caller: (...)length: 0
name: "reactiveGetter"
prototype: {
    
    constructor: ƒ}

基础不够扎实没有搞清楚数据类型。
后端返回的数据类型应与前端保持一致。

猜你喜欢

转载自blog.csdn.net/weixin_41481695/article/details/108373314
今日推荐