MBP: Mid 2014, the system is OS X 10.11 El Capitan iMac: Mid 2011, the system is OS X 10.11 El Capitan
After connecting with the Thunderbolt data cable (not MiniDP), press Cmd+F2 on the iMac and only hear a beep without switching to the extended screen.
It can be extended on another iMac of the same model with OS X 10.10 Yosemite installed, and it cannot be extended on this iMac with MiniDP cable.
For specific models and corresponding data cables, please refer to: https://support.apple.com/en-us/HT204592
I currently plan to reinstall the iMac back into Yosemite.
After an afternoon of tossing, I finally found a solution
OS X 10.11 El Capitan does not seem to support TDM at the moment, so I reinstalled the iMac back to OS X 10.10 Yosemite by reference: http://www.macworld.co.uk/how-to/mac-software/delete-el-capitan-beta-go-back-to-yosemite-3581872/, the version is 10.10.5.
But there is a pitfall here is that the old G5 wired full keyboard used by iMac can only hear a "beep" when pressing Cmd+F2, which is the sound of system invalid keys, because the shortcut key for switching TDM is not standard Cmd+F2 It is cmd + the function key to increase the screen brightness, which can be switched by using the Bluetooth keyboard with the corresponding function key.
Tossing for a long time to solve this problem is to use an Apple keyboard with multimedia (F1 and F2 are for brightness adjustment), and at the same time connect the old G5 or other non-Apple keyboards, and install a BetterTouchTool on the iMac. Binding ⌘+F2 is ⌘+☀, but this method can only cut in but not out, because there is no way to activate the shortcut keys bound to BetterTouchTool in the TDM state, so it is better to change the keyboard.