<template>
    <div id="token">{{token}}</div>
    <input type="text" id="student_id" v-model="student_id" >
    <input type="button" id="getToken" @click='getToken' value="getToken">
</template>

<script>
    export default {
        name: "Login_1",
        data(){
            return{
                proxy:"/examServer",
                url:"public_api/v1/api_for_vue_exam_2",
                token:"no token",
                student_id:"202140701358",
            }
        },
        methods:{
            getToken(){

                const formData = new FormData();

                formData.append("student_id",this.student_id);

                let url = this.proxy+this.url;
                let that = this;

                this.axios.post(
                    url,
                    formData,
                    {
                        headers: {
                            'Content-Type': 'multipart/form-data'
                        }
                    }

                ).then(
                    function (response) {
                        that.token = response.data;
                    },
                    function (error) {
                        console.log("有可能是防火墙没有开");
                        console.log(error.data);
                    }
                )

            },
        },
        mounted() {
            window.myVue=this;
        }
    }
</script>

<style scoped>

</style>