zoukankan      html  css  js  c++  java
  • vue-resource

    Resource

    The resource service can be used globally Vue.resource or in a Vue instance this.$resource.

    resource服务可以被全局使用 :Vue.resource  或者在vue实例中this.$resource

    Methods

    resource(url, [params], [actions], [options])

    Default Actions

    get: {method: 'GET'},
    save: {method: 'POST'},
    query: {method: 'GET'},
    update: {method: 'PUT'},
    remove: {method: 'DELETE'},
    delete: {method: 'DELETE'}

    Example

    {
      var resource = this.$resource('someItem{/id}');
    
      // GET someItem/1
      resource.get({id: 1}).then((response) => {
        this.$set('item', response.json())
      });
    
      // POST someItem/1
      resource.save({id: 1}, {item: this.item}).then((response) => {
        // success callback
      }, (response) => {
        // error callback
      });
    
      // DELETE someItem/1
      resource.delete({id: 1}).then((response) => {
        // success callback
      }, (response) => {
        // error callback
      });
    }

    Custom Actions

    {
      var customActions = {
        foo: {method: 'GET', url: 'someItem/foo{/id}'},
        bar: {method: 'POST', url: 'someItem/bar{/id}'}
      }
    
      var resource = this.$resource('someItem{/id}', {}, customActions);
    
      // GET someItem/foo/1
      resource.foo({id: 1}).then((response) => {
        this.$set('item', response.json())
      });
    
      // POST someItem/bar/1
      resource.bar({id: 1}, {item: this.item}).then((response) => {
        // success callback
      }, (response) => {
        // error callback
      });
    }
    请把你的疑问评论在下方。
  • 相关阅读:
    基础
    条件语句/变量和基本数据类型
    编程语言介绍
    asp.net中log4net使用方法
    web布到服务器上出错
    《转》IEnumerable、IEnumerator两个接口的认识
    异步ADO.NET
    Session的使用
    AJAX参数及各种HTTP状态值
    简易的抓取别人网站内容
  • 原文地址:https://www.cnblogs.com/zzcit/p/6041564.html
Copyright © 2011-2022 走看看