zoukankan      html  css  js  c++  java
  • vue的学习-axios (六)

    axios的学习

    <!DOCTYPE html>
    <html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"
          xmlns:v-on="http://www.w3.org/1999/xhtml"
    >
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <style>
        [v-clock]{
            display: none;
        }
    </style>
    <body>
    <div id="app" v-clock>
        <div>{{info.name}}</div>
        <div>{{info.address.country}}</div>
        <a v-bind:href="info.url">点我</a>
    
    </div>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        let vm = new Vue({
            el: "#app",
            data(){
               return {
                   //请求的返回的参数格式 ,必须和JSON 字符串一样
                   info: {
                       name: null,
                       address: {
                           country: null,
                       },
                       url: null
                   }
               }
            },
            mounted(){ //钩子函数
                axios.get("demo02.json").then(response=>(this.info=response.data));
            }
        })
    </script>
    </body>
    </html>

     demo02.json

    demo02.json 文件的内容
    {
      "name": "李辉",
      "url": "https://www.cnblogs.com/lihui123/",
      "page": 1,
      "inNonProfit": true,
      "address": {
        "street": "含光门",
        "city": "陕西西安",
        "country": "中国"
      },
      "links": [
        {
          "name": "博客园",
          "url": "https://www.cnblogs.com/lihui123/"
        },
        {
          "name": "李辉",
          "url": "https://www.cnblogs.com/lihui123/"
        },
        {
          "name": "百度",
          "url": "https://www.cnblogs.com/lihui123/"
        }
      ]
    }
  • 相关阅读:
    Scrapy框架
    描述符类
    完整的blog设计过程
    钉钉机器人设置步骤
    homework登录和支付mock两个接口
    jsonpath的用法和nnlog的使用
    mp4格式文件转码后处理(qt-faststart).md
    html5视音频标签参考.md
    ffmpeg文档43-开发者
    ffmpeg文档42-参考/看
  • 原文地址:https://www.cnblogs.com/lihui123/p/14192589.html
Copyright © 2011-2022 走看看