首页 文章

包含jquery和bootsrap时,模块解析失败

提问于
浏览
0

我在.vue文件中添加了SB Admin模板,

当我在 main.js 中包含 jquery.jsbootstrap.js 时,它会返回以下错误:

./~/bootstrap/dist/js/jquery.js中的错误 . 模块解析失败:E:\ swapnil \ sanskar \ front \ node_modules \ bootstrap \ dist \ js \ jquery.js意外的令牌(7586:0)你可能需要适当的加载器来处理这种文件类型 . SyntaxError:Parser.pp $ 4.raise(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:2221:15)中的意外标记(7586:0),位于Parser.pp.unexpected(E:\在Parser.pp $ 3.parseExprAtom(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:1822:12 )在Parser.pp $ 3.parseExprSubscripts(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:1715:21)at Parser.pp $ 3.parseMaybeUnary(E:\ swapnil \ sanskar \ front \ node_modules) \ acorn \ dist \ acorn.js:1692:19)at Parser.pp $ 3.parseExprOps(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:1637:21)at Parser.pp $ 3 . parseMaybeConditional(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:1620:21)at Parser.pp $ 3.parseMaybeAssign(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn . js:1597:21)在Parser.pp $ 3.parseExpression(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:1573:21)at Parser.pp $ 1.parseStatement(E:\ swapnil \ sanskar \前\ node_modules \橡子\ DIST \交流orn.js:727:47)在Parser.pp $ 1.parseBlock(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:981:25)at Parser.pp $ 3.parseFunctionBody(E:\在Parser.pp $ 1.parseFunction(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:1065:10 )在Parser.pp $ 3.parseExprAtom(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:1810:19)at Parser.pp $ 3.parseExprSubscripts(E:\ swapnil \ sanskar \ front \ node_modules) \ acorn \ dist \ acorn.js:1715:21)在Parser.pp $ 3.parseMaybeUnary(E:\ swapnil \ sanskar \ front \ node_modules \ acorn \ dist \ acorn.js:1692:19)@ ./src/main .js 19:0-54

我正在使用jquery版本: 2.1.4 和bootstrap版本: 3.3.7 ,有谁能告诉我这方面的解决方案?

1 回答

  • 0

    您可以在main,js中使用ES2015语法

    npm install jquery --save-dev

    import $ from 'jquery';
    // or
    import jQuery from 'jquery';
    
    // export for others scripts to use
    window.$ = $;
    window.jQuery = jQuery;
    

    同样适用于引导程序或来自npm的任何其他依赖项

相关问题