reply$right = $list->toArray(); This is indeed no problem, as is the image you uploaded.
The problem lies in: the paginate function requires one more layer.
Still no problem, the return values of the two functions paginate and select are different.
replyNot modified:
In the console: 'status' => isset($param['status']) ? $param['status'] : 0,//This is 0, I reported an error today
In view: <td>{if $right_v['status']==1}on{else/}off{/if}</td>
After modification:
In the model: public function getStatusAttr($v){
$status = [
1=>'Open',
2=>'Close'
];
return $status[$v];
}
In the console: 'status' => isset($param['status']) ? $param['status'] : 1,//No error will be reported in this way
In view: <td>{$right_v['status']}</td>
replyThe paginate function does have one more layer.
Directly use $right = $list->toArray(); There is an error in traversal in my code, hahaha, I don’t know why.
In the end I still used your code in the model
replyOh, and one more thing:
You can find this [view code: edit.html] in [thinkphp6.0 request], there are three edit.html [should be edit.html, add.html, index.html]
replyCould you please tell me how you write to switch [content on the right]? I wrote some myself today: https://blog.csdn.net/mixintu/article/details/104302187
$right = $list->toArray();
I’ve seen this and it’s no problem. No need to add another layer of ["data"];
Error, please send a screenshot for me to take a look at.