Knockout.js won't be recognized after using require.js

白昼怎懂夜的黑 提交于 2019-12-13 10:19:51

问题


Calling require.js before knockout.js throws the following message:

Uncaught ReferenceError: ko is not defined

Assuming I have knockout.js at the very top of the combined file, I have this:

<script type="text/javascript" src="/bower_components/requirejs/require.js"></script>
<script type="text/javascript">
    requirejs.config({
        paths: {
            text: '/bower_components/text/text'
        },
    });

    requirejs([
        '/bower_components/text/text.js'
    ]);
</script>
<script type="text/javascript" src="/js/dist/combined.min.js"></script>

回答1:


When Knockout detects RequireJS, it doesn't create a global ko object but expects you to use define to get the object.



来源:https://stackoverflow.com/questions/39515390/knockout-js-wont-be-recognized-after-using-require-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!