当前位置 : 主页 > 网页制作 > HTTP/TCP >

vuebase--9._axios post请求

来源:互联网 收集:自由互联 发布时间:2021-06-16
1.axios-post请求 template lang="html" div class="hello" HelloWorld! /div /template script import qs from "qs"; // 解决参数格式的转码问题 ?name=xxxxxage=100 {name:ixxxxx,age:100} export default { name: ‘HelloWorld‘, data() {

1.axios-post请求

 

<template lang="html">
<div class="hello">
HelloWorld!
</div>
</template>

<script>
import qs from "qs"; // 解决参数格式的转码问题 ?name=xxxxx&age=100 {name:ixxxxx,age:100}
export default {
name: ‘HelloWorld‘,
data() {
return {
msg: ‘Welcome to Your Vue.js App‘
}
},
mounted() {
/* this.$axios.get("xxxx")
.then(res => {
console.log(res.data)
}).catch(error => {
console.log(error);
}) */
this.$axios.post("xxx",qs.stringify({
uers_id:"12345",
password:"1234567890"
})).then(res =>{
console.log(res.data)
}).catch(error=>{
console.log(error)
})
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
font-weight: normal;
}

ul {
list-style-type: none;
padding: 0;
}

li {
display: inline-block;
margin: 0 10px;
}

a { color: #42b983; }</style>

网友评论