项目错误与解决方法

2021/9/14 23:09:36

本文主要是介绍项目错误与解决方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.index.html:180 Uncaught SyntaxError: Invalid shorthand property initializer

跟踪控制台一直出现这个错误


如下是错误JSON

//错误:本质原因是 “ = ”应该写为“ :”,可以说小小的符号毁所有
//获取用户信息  死亡回调
    var token = sessionStorage.getItem("token")
    $.ajax({
        url: "http://39.103.220.191:8888/user/info?token=" + sessionStorage.getItem("token"),
        contentType= "application/json",
        headers= {
            "Authorization": token
        },
        success=function (res) {
            console.log(res);
            $(".user").append(res.data.username)
        }
    })


//正确写法
//获取用户信息  死亡回调
    var token = sessionStorage.getItem("token")
    $.ajax({
        url: "http://39.103.220.191:8888/user/info?token=" + sessionStorage.getItem("token"),
        contentType: "application/json",
        headers: {
            "Authorization": token
        },
        success: function (res) {
            console.log(res);
            $(".user").append(res.data.username)
        }
    })



这篇关于项目错误与解决方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程