vue axios

简单示例

"dependencies": {
    "axios": "^0.18.0",
    "element-ui": "^2.4.11",
    "js-cookie": "^2.2.0",
    "vue": "^2.5.2",
    "vue-router": "^3.0.1"
  },

 

devDependencies
"mockjs": "^1.0.1-beta3",

<script>
import axios from axios
import mock from @/mock/mock.js
export default {
  name: Home,
  methods: {
    testAxios() {
      axios.get(http://localhost:8080).then(res => { alert(res.data) })
    },
    getUser() {
      axios.get(http://localhost:8080/user).then(res => { alert(JSON.stringify(res.data)) })
    },
    getMenu() {
      axios.get(http://localhost:8080/menu).then(res => { alert(JSON.stringify(res.data)) })
    }
  }
}
</script>

 

vue axios

上一篇:ObjectMapper采坑记及源码分析


下一篇:python爬虫