我有2个js文件,代码如下
index.js
const Alert = ( ($) => {
class Alert {
constructor(element) {
this._element = element
}
}
return Alert
} )( $ )
export default Alert
和 source1.js
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Alert = undefined;
var _source = require('./source1');
var _source2 = _interopRequireDefault(_source);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
(function ($) {
var version = $.fn.jquery.split(' ')[0].split('.');
})($);
exports.Alert = _source2.default;
当我在prepros应用程序中使用babel编译index.js时。 我得到以下编译的代码
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta content="X-Content-Type-Options: nosniff">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="/src/verbatims.js" type="application/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>
<title>My project</title>
</head>
<body>
<div id="data">
Le nombre de requête est de : {{ request }}<br>
<button v-on:click="change">Change value</button>
<button v-on:click="stop">Arrêter</button>
</div>
<script>
let app = new Vue({
el:'#data',
data: {
request: "toto",
ite: 0
},
methods: {
change: function() {
changeNbRequest()
},
stop: function() {
clearInterval()
}
}
});
changeNbRequest = function() {
var timer = setInterval(function() {
let verbatim = new Verbatims().list()[ite];
}, 5000);
}
</script>
</body>
</html>
从编译后的源代码中我可以看到source1.js没有合并。