Nowadays, with the gradual development of intelligent transportation and the widespread popularity of private cars, the Internet of Vehicles (IoV) technology is gradually coming to maturity. However, the development of smart cars has been accompanied by a concomitant increase in the amount of media as well as video games in the vehicle, and an explosion in the demand for computational resources. Since smart cars have limited computing resources of their own, they cannot store a large number of pending tasks in their own queues, so they cannot compute the large number of requests generated by the vehicles themselves. The lack of computing resources can be better solved with the help of edge servers, and the distribution of edge servers close to the user side of the road can also effectively achieve real-time for resource requests, but the high energy consumption generated during processing is also a challenge we must face. To address this challenge, a joint task offloading approach based on mobile edge computing and fog computing (EFTO) proposed in this paper. Technically, the location of the processing task is first obtained by getting the route of the computing task, thus finding the complete routing information of the task from the initial location to the target location. Then, a genetic algorithm is used to implement a multi-objective optimization problem to reduce the time and energy consumption during offloading and processing. Finally, the effectiveness of EFTO is demonstrated through comparative experiments, which shows a reduction in time consumption and an optimization of energy consumption compared to other offloading methods.