例如:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
{{ message }}
</div>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js'></script>
<script src="app.js"></script>
</body>
</html>
app.ts:
import { Vue } from "vue/types/vue";
let vue = new Vue({
el:"#app",
data:{
text:"hello world"
}
})
在cmd tsc
之后,它将在js下面生成
"use strict";
exports.__esModule = true;
var vue_1 = require("vue/types/vue");
var vue = new vue_1.Vue({
el: "#app",
data: {
text: "hello world"
}
});
我希望禁用生成“ exports .__ esModule = true;”和“ require(” lib“);”
var vue = new Vue({
el: "#app",
data: {
text: "hello world"
}
});
我使用DefinitelyTyped来获得确定的类型
答案 0 :(得分:1)
将您的 tsconfig.json module
更改为es2015
,将moduleResolution
更改为node
。
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node"
}
}
transpile from an ES module to commonjs(使用babel或TypeScript)会发生exports.__esModule
和require('lib')
。