In requireJS, there is a property called baseURL. By setting the baseURL, we can write the file path that needs to be loaded relative to the project, not relative to the current page.
For example: Suppose our project directory is /myproject/, which has two pages, one is /myproject/one.html, and the other is /myproject/html/other.html, and they all need to load /myproject/js/some.js. If we set the baseURL to /myproject/, when we load the js, both pages can use the path relative to the project./js/some, instead of using different relative paths because the page path is different.
But if we don't use requireJS, can we implement functions similar to baseURL?
Base tag In fact, there is a base tag in HTML that can produce similar functions. For example:Copy the code