Here is my Code, how to and pass data from controller to layout
$arr = array();
$arr['layout'] = 'example';
$this->layout()->calllayout = $arr;
试试这样
$this->layout()->setVariable('var', $data);
Before ViewModel Write serVariable by $this->layout() like:
$arr = array();
$arr['layout'] = 'example';
$this->layout()->setVariable('variableName', $arr);
and Access it like :
echo $this->variableName['layout'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.