簡體   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