zoukankan      html  css  js  c++  java
  • vue全局配置域名

     // 如果我们通过全局配置了,请求的数据接口 根域名,则 ,在每次单独发起 http 请求的时候,请求的 url 路径,应该以相对路径开头,前面不能带 /  ,否则 不会启用根路径做拼接;
        Vue.http.options.root = 'http://vue.studyit.io/';
    复制代码
    getAllList() { // 获取所有的品牌列表 
              // 分析:
              // 1. 由于已经导入了 Vue-resource这个包,所以 ,可以直接通过  this.$http 来发起数据请求
              // 2. 根据接口API文档,知道,获取列表的时候,应该发起一个 get 请求
              // 3. this.$http.get('url').then(function(result){})
              // 4. 当通过 then 指定回调函数之后,在回调函数中,可以拿到数据服务器返回的 result
              // 5. 先判断 result.status 是否等于0,如果等于0,就成功了,可以 把 result.message 赋值给 this.list ; 如果不等于0,可以弹框提醒,获取数据失败!
    
              this.$http.get('api/getprodlist').then(result => {
                // 注意: 通过 $http 获取到的数据,都在 result.body 中放着
                var result = result.body
                if (result.status === 0) {
                  // 成功了
                  this.list = result.message
                } else {
                  // 失败了
                  alert('获取数据失败!')
                }
              })
            },
    复制代码
  • 相关阅读:
    洛谷3163 CQOI2014危桥 (最大流)
    UVA557 汉堡 Burger
    洛谷1950 长方形 (单调栈)
    洛谷3317 SDOI2014重建(高斯消元+期望)
    洛谷4035 JSOI2008球形空间产生器 (列柿子+高斯消元)
    test1
    test
    background
    bzoj1075
    bzoj1074
  • 原文地址:https://www.cnblogs.com/xzhce/p/12905281.html
Copyright © 2011-2022 走看看