Giter VIP home page Giter VIP logo

Comments (3)

errorrik avatar errorrik commented on July 17, 2024

经过测试,不是bug。下面的测试代码是能跑通的

<script src="esl.js"></script>
<script>
require(['test.mod'], function (mod) {
    alert(mod.name)
});
</script>
// test.mod.js
define({name:'test.mod'});

另,经过分析,jquery的源码中是通过具名id的方式声明模块的:

define("jquery",[], ...);

如果你是 require(['jquery-1.11.1']), 那么很明显,肯定是不行的,因为声明的模块是jquery而不是jquery-1.11.1。

解决办法是:既然模块名和其路径不是完全对应的,那么可以通过paths配置项配置下

<script src="esl.js"></script>
<script>
require.config({
    paths: {
        jquery: 'path/jquery-1.11.1'
    }
});
require(['jquery'], function (jquery) {
    // ......
});
</script>

from esl.

gudaozr avatar gudaozr commented on July 17, 2024

非常感谢您的回复和解惑!水平有限,给您添麻烦了!

from esl.

errorrik avatar errorrik commented on July 17, 2024

不会,能解决问题就好

from esl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.