A rookie problem, which is a controller of ThinkPHP, calls other methods to print $this- > accounts is [],
whether to render index or not, the life cycle of this controller instance is over. When routing access to other methods, the instance will be created again, and the database needs to be called again
class Index extends Controller {
private accounts = [];
public function index() {
// 1.
$this->accounts = model("Account")->getAccounts(); // $this->accounts
return $this->fetch("", [
"list" => $this->accounts,
]);
}
public function select($id) {
dump($this->accounts); // index
}
}