【问题标题】:ExtJS RPC doesn't work with exact classExtJS RPC 不适用于确切的类
【发布时间】:2017-08-07 07:50:32
【问题描述】:

我有用 Laravel 编写的 API。类示例:

/**
* Class MRoleController
* @package App\Http\Controllers\API
*/

class MRoleAPIController extends BaseApiController
{
/** @var  MRoleRepository */
private $mRoleRepository;

public function __construct(MRoleRepository $mRoleRepo)
{
    $this->mRoleRepository = $mRoleRepo;
}

/**
 * @param Request $request
 * @return Response
 *
 * @SWG\Get(
 *      path="/m_roles",
 *      summary="Get a listing of the MRoles.",
 *      tags={"MRole"},
 *      description="#Get all MRoles",
 *      produces={"application/json"},
 *      @SWG\Response(
 *          response=200,
 *          description="successful operation",
 *          @SWG\Schema(
 *              type="object",
 *              @SWG\Property(
 *                  property="success",
 *                  type="boolean"
 *              ),
 *              @SWG\Property(
 *                  property="data",
 *                  type="array",
 *                  @SWG\Items(ref="#/definitions/MRole")
 *              ),
 *              @SWG\Property(
 *                  property="message",
 *                  type="string"
 *              )
 *          )
 *      )
 * )
 * 
 * @direct
 */
public function index($request = false)
{
    return parent::getAll($request, $this->mRoleRepository);
}

我有另一个带有方法的类,并且 RPC 可以正确使用它们。

在浏览器控制台中,我收到两个错误:

  1. Ext.direct.Manager.resolveApi():无法解析 Direct API 方法 'API.MRole.index' 用于 Ext.data.proxy.Direct 实例中的读取操作 id:未知

  2. 未捕获的错误:无法解析 Direct API 方法“API.MRole.index” 读取 ID 为未知的 Ext.data.proxy.Direct 实例中的操作

ExtJS 模型,我在这里尝试使用这个类:

Ext.define('AIS.model.role', {
extend: 'Ext.data.Model',
alias: 'model.role',

requires: [
    'Project.DirectAPI',
    'Ext.data.field.Integer',
    'Ext.data.field.String',
    'Ext.data.proxy.Direct',
    'Ext.data.reader.Json'
],

idProperty: 'Role_id',

fields: [
    {
        type: 'int',
        name: 'RoleId'
    },
    {
        type: 'string',
        name: 'RoleName_RU'
    },
    {
        type: 'string',
        name: 'RoleName_UZ'
    },
    {
        type: 'string',
        name: 'RoleName_EN'
    }
],

proxy: {
    type: 'direct',
    api: {
        read: 'API.MRole.index',
        create: 'API.MRole.store',
        update: 'API.MRole.update',
        destroy: 'API.MRole.destroy'
    },
    reader: {
        type: 'json',
        rootProperty: 'data',
        totalProperty: 'totalCount'
    }
}
}); 

感谢您的回答。

【问题讨论】:

  • UPD:ExtJS 版本 - 6.2

标签: javascript php laravel extjs rpc


【解决方案1】:

我解决了这个问题。事实证明,我忘记在 ext-direct.php 配置中添加“MRole”类。

【讨论】:

    猜你喜欢
    • 2016-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-08
    • 2015-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多