Using requireJs, you can refer to each component in a modular way, so that you can write it once and use it multiple times.
(1) Download requireJS
(2) Placed under a specific directory, the directory location is not fixed
(3) Configure the configuration parameters of requireJS
(4) Configure dependencies to resolve non-modular function references
Super points to pay attention to:
The way to import a module component using require in HTML is:
<script src="${ctx}/assets/js/require.js" data-main="${ctx}/assets/js/51Share/index"></script>
The src and data-main parameters are directly irrelevant! ! ! ! ! ! ! ! ! The path here must be the path of html relative to the two js! ! ! ! Don't be confused! ! ! ! ! Otherwise it will keep reporting "unexpected token <" !!!!!!! This is misleading (took an hour to check the problem)