木子炜培先生

⑴2017底=>(年薪15万)=>31岁 ⑵2018=》(生产生活用品)并且年薪20万=>32岁 ⑶2019=>年薪30万=>把小作坊升级为工厂=>33岁 ⑷2020=>再开一个食品工厂

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
1引入vue-resource
    import VueResource from 'vue-resource'
    Vue.use(VueResource);

2

    postGetListJson(newIndex){
        let url=`http://api.v.com/index.php?r=v1/user/test`
        Vue.http.get(url).then((response) => { 
            alert(response);
        });
    },

 

 php服务端添加函数

3

   public function beforeAction($action)
    {
        header('Access-Control-Allow-Origin:'.\Yii::$app->params[ 'clientDomain']);
        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }

 

 

 

 

可选  4

location /rest {
add_header Access-Control-Allow-Origin "*";
...
}

 

 

其他

// global Vue object
Vue.http.get('/someUrl', [data], [options]).then(successCallback, errorCallback);
Vue.http.post('/someUrl', [data], [options]).then(successCallback, errorCallback);

// in a Vue instance
this.$http.get('/someUrl', [data], [options]).then(successCallback, errorCallback);
this.$http.post('/someUrl', [data], [options]).then(successCallback, errorCallback);

 

new Vue({
    ready() {
      // GET request
      this.$http.jsonp('/someUrl', {xxx:"xxxx"})
        .then(function (response) {
          console.log(response.data)
      }, function (response) {
          // error callback
      });
    }
})

 

posted on 2017-02-14 02:22  木子炜培先生  阅读(1521)  评论(0编辑  收藏  举报