System.js可以取代require.js吗 [英] Can system.js replace require.js
问题描述
我在一个大型项目中使用requirejs.该项目将很快升级到angular2.
I'm using requirejs in a large project. This project will soon be upgraded to angular2.
Angular2使用system.js,因此我也在考虑切换到system.js.我是否应该能够删除对requirejs库的引用并改为包含system.js并期望它能正常工作,或者我在这里不了解某些内容?
Angular2 uses system.js, so I'm thinking of switching to system.js too. Should I be able to remove the reference to the requirejs library and include system.js instead and expect it to work, or is there something I don't understand here?
我尝试通过仅删除require.js文件并添加system.js文件来尝试,但是收到错误消息,指出define未定义. 你能帮我吗?除了system.js之外,我还需要require.js吗?
I tried by just removing the require.js file and adding the system.js file instead, but I get error messages saying define is not defined. Can you help? Will I need require.js in addition to system.js?
推荐答案
我也刚切换到system.js.您需要用system.js替换require.js并添加简单的脚本标记.所以它应该像这样:
I just switched to system.js too. You need to replace your require.js with system.js and add simple script tag. So it should look like this:
<script src="~/lib/system.js/dist/system.js" type="text/javascript"></script>
<script>
// set our baseURL reference path
System.config({
baseURL: '/app'
});
System.import('startup.js');
</script>
这篇关于System.js可以取代require.js吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!