Attention and working memory are important cognitive functions that affect junior school students’ learning ability and academic performance. This study aimed to explore the relationships among trait mindfulness, attention, and working memory and to explore differences in performance between a high trait mindfulness group and a low one in attention and working memory under different stressful situations. In study 1, 216 junior school students completed the Five Facet Mindfulness Questionnaire (FFMQ), and their attention and working memory were tested in a non-pressure situation. The results showed that attention had a partial mediating effect between mindfulness and working memory. In study 2, the high trait mindfulness group and the low one were tested for attention and working memory under situations with single and multiple pressures. One notable result was that the attention and working memory performances of the high mindfulness group were all significantly higher than those of the low mindfulness group in every stress situation (no stress, single stress, and multiple stresses). Other important results were that trait mindfulness moderates the relationship between stress and attention and between stress and working memory. These results suggest that trait mindfulness has a protective effect in the process by which various stresses affect attention and working memory. These findings indicate that trait mindfulness is an important psychological quality that affects the attention and working memory of junior school students, and it is also an important psychological resource for effectively coping with the impact of stress on attention and working memory. Therefore, it is possible that improving trait mindfulness may help to improve junior school students’ attention and working memory and enable them to cope better with stress, thereby helping to improve academic performance. This research is of great significance for understanding the association between key psychological qualities and cognitive functions in different stressful situations. These findings also provide insight for future studies in educational psychology.