繁体   English   中英

ExtJS RPC不适用于确切的类

[英]ExtJS RPC doesn't work with exact class

我有用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():无法为ID为:未知的Ext.data.proxy.Direct实例中的读取操作解析Direct API方法'API.MRole.index'

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

我尝试在其中使用此类的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'
    }
}
}); 

感谢您的回答。

我解决了问题。 原来,我忘了在ext-direct.php配置中添加“ MRole”类。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM