问题
I'm developing an app that uses a certain site to make payments easier, and the way it handles payments requires to import some javascript from this url https://bridge.paymill.com/ that contains the script.
The fact is, I'm using require js to load all the scripts, in my main.js configuration, I'm trying to make it this way:
requirejs.config({
...
'paymill': 'https://bridge.paymill.com/',
...
});
But this, of course, tries to fetch from https://bridge.paymill.com/.js, which is not the correct url (it's without the last .js)
How could I notify requirejs to load this without appending '.js' at the end?
回答1:
Put a question mark at the end of the URL
requirejs.config({
...
'paymill': 'https://bridge.paymill.com/?',
...
});
How this works:
https://bridge.paymill.com/?.js is a valid URL with .js as a GET request.
来源:https://stackoverflow.com/questions/20100575/how-do-i-make-require-js-fetch-a-script-that-does-not-end-in-js