Axios入门

用于网络通信


<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>demo01title>
  <style>
    [v-clock] {
      
      display: none;
    }
  style>
head>
<body>
<script src="https://cdn.jsdelivr.net/npm/vue">script>
<script src="https://unpkg.com/axios/dist/axios.min.js">script>

<div id="app" v-cloak>
  <div>{
    {info.id}}div>
  <div>{
    {info.name}}div>
  <div>{
    {info.age}}div>
  <div>{
    {info.email}}div>
  <div>{
    {info.hobby}}div>
  <a v-bind:href="info.url">baidua>
div>

<script>
  var app = new Vue({
      
    el: '#app',
    data(){
      
      return{
      
        info: {
      
          id: null,
          name: null,
          age: null,
          email: null,
          hobby: null,
          url: null
        }
      }
    },
    mounted(){
       //钩子函数
      axios.get('data.json').then(response=>(this.info=response.data));
    }
  })
script>
body>
html>

你可能感兴趣的:(axios)