magento2 要返回数据问题?

4.96K 浏览M2交流区

magento2 要返回数据问题?

是用 return  “ok”  还是$this ->response("ok");  还是有其他 ,第一个我执行还是报错的 说无法识别类型

0
//在 __construct方法中注入 MagentoFrameworkControllerResultJsonFactory
 public function __construct(
        MagentoFrameworkControllerResultJsonFactory $jsonFactory
    ) {
        $this->jsonFactory = $jsonFactory;
    }

//在方法中使用
$resultJson = $this->jsonFactory->create();
return $resultJson->setData($data);

0
您正在查看2个回答中的1个,单击此处查看所有回答。