This paper studies the mirror descent algorithm for distributed optimization, where the underlying digraph is assumed to be weight-unbalanced. Within this framework, a novel distributed mirror descent algorithm based on gradient weighting technique is developed. Theoretically, different from the existing works, which prove that the function value corresponding to the estimates converge to the optimal value of the optimization problem, this paper proves that (1) the proposed algorithm can achieve exact convergence of the estimates to the solution of the optimization problem; and (2) the algorithm has a convergence rate O(1T) with a given time horizon T. Further, taking into account the fact that the cost functions in many significant optimization problems are dynamic, the distributed online optimization based on the proposed algorithm is studied. Especially, it is shown that the individual regret of the proposed algorithm is bounded by O(T). Finally, the theoretical results are verified through some simulation examples.