Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

我想将input里的字段发送给后端,但是我在network里的请求中没有看到id这个字段?不知道是不是发送成功了

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div id="search">
        <input type="text" v-model='input'>
        <button @click='getData'>查询</button>

        <div class="msg">{{msg}}</div>
    </div>
</body>
<script src='vue.js'></script>
<script src='vue-resource.js'></script>
<script>
    new Vue({
        el:"#search",
        data:{
            input:"",
            msg:""
        },
        methods:{
            getData(){
                this.$http.get("test.json",{id:this.input}).then(res=>{
                    console.log(res.data)
                    this.msg=res.data
            })
            }
        }

    })
</script>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
437 views
Welcome To Ask or Share your Answers For Others

1 Answer

getData(){
    this.$http.get("test.json",{params: {id:this.input}}).then(res=>{
        console.log(res.data)
        this.msg=res.data
    })
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...