我有两个组成部分:
父组件是类组件,子组件是功能组件。从父组件调用子方法的最佳实践是什么?
这些组件的目标是能够动态加载 svg 文件。
父组件:
class UnitMonitor extends PureComponent {
constructor() {
super();
}
state = {
img: null,
};
onChangeShcema = schemaID => {
axios.get("/api/schemata/get-schemata-nodes/" + schemaID).then(response => {
let path = response.data["0"]["file"];
// call loadFile function of child component is needed
});
render() {
return (
<Row type="flex" className="">
<Col span={25}>
<SvgViewer />
</Col>
</Row>
);
}
};
Run Code Online (Sandbox Code Playgroud)
子组件:
const SvgViewer = () => {
const loadFile = path => {
let svgFile = require("./images/" …Run Code Online (Sandbox Code Playgroud) 我想在我的网站的标题和其他一些视图中显示未读邮件的数量。为此,我编写了一个全局中间件,但该中间件无法访问已注册用户的身份验证信息。
<?php
namespace PTA_OIMS\Http\Middleware;
use Illuminate\View\Factory;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use PTA_OIMS\Kartable;
use Session;
class UnreadMessage
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
protected $auth;
protected $view;
public function __construct(Guard $auth, Factory $view)
{
$this->auth = $auth;
$this->view = $view;
}
public function handle($request, Closure $next)
{
$unreadMessage = NULL;
$user = $this->auth->check();
if (!empty($user)) {
$unreadMessage = Kartable::
where('id_reciver', '=',
Session::get('personnel_info.0')->box_id)
->whereBetween('status', [1, 2])
->where('view_date', '=', …Run Code Online (Sandbox Code Playgroud) 在没有使用VerifyCsrfToken middelware和$ except []数组的情况下,Laravel 5.2中是否有任何方法可以禁用所有路由的csrf保护?