Not any dish can you add salt directly when cooking. In particular, when cooking root vegetables, you should put salt earlier so that the root vegetables can absorb the marinade.
However, when boiling leaf vegetables, you had better add salt right before you turn off the heat to avoid the loss of nutrients. Moreover, if salt is added too early, it will cause the vegetables to become red or yellow, losing the beautiful green color.