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/"
        }
      ]
    }
  • 相关阅读:
    注释
    Servlet原理和开发
    什么是Servlet
    Java基础目录
    实现第一个Servlet
    Servlet的体系
    习题3
    利用ResultFilter实现asp.net mvc3 页面静态化
    oracle欲出纯托管代码的ODP.NET,现接受小范围预览版本使用申请
    http请求头中包含未编码中文时webapi self host崩溃
  • 原文地址:https://www.cnblogs.com/lihui123/p/14192589.html
Copyright © 2011-2022 走看看