第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

webpack打包原生js

webpack打包原生js

qq_笑_17 2019-02-21 13:19:48
我要用webpack打包原生js,然后寫了個小demo測試一下:我寫了個test.js文件module.exports = {    alertMsg:function(){        alert(1);    }}然后在入口文件entry.js里面導(dǎo)入這個文件'use strict';let a = require('./home/test.js');module.exports = {a};下面index.html文件<!DOCTYPE html><html><head>    <meta charset="utf-8"/>    <script src="./common/jquery.min.js"></script>    <script src="./bundle.js"></script></head><body>    <div id="head"></div>    <div>        <button id="btn" onclick="alertMsg()">click</button>    </div></body><script>    window.alertMsg = a.alertMsg;</script></html>提示a未定義,我不知道是哪里理解出錯,是對es6的module?!迫切希望得到幫助。。。感謝
查看完整描述

2 回答

?
紅顏莎娜

TA貢獻(xiàn)1842條經(jīng)驗 獲得超13個贊

這....

在entry.js中, 的確有export a這個變量, 但這些都是在ES6的環(huán)境下.你可以再添加一個新的文件, 如demo.js:
let a = require('./entry.js')
然后再去使用它.

但如果像
window.alertMsg = a.alertMsg, 這么寫肯定不對的.


查看完整回答
反對 回復(fù) 2019-02-26
  • 2 回答
  • 0 關(guān)注
  • 1523 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號