23、Vue-axios基本使用
8049 ワード
23、Vue-axios基本使用
<html>
<head>
<meta charset="utf-8">
<title> title>
head>
<body>
<div id="app">div>
body>
<script type="text/javascript" src="js/vue.js">script>
<script type="text/javascript" src="./node_modules/axios/dist/axios.js">script>
<script type="text/javascript">
// Vue.use(axios) //
Vue.prototype.$axios = axios;
var App={
template:`
`,
methods:{
//
senAjax(){
this.$axios.get('http://127.0.0.1:8888/')
//
.then(res=>{
console.log(res);
})
//
.catch(err=>{
console.log(err)
})
}
}
};
new Vue({
el:'#app',
data(){
return {
}
},
template:`` ,
components:{
App
}
});
script>
html>