@@ -15,4 +15,4 @@ vue2:vue create 项目名
1.配置node环境: node -v
vue3:
安装命令:npm create vue@latest
-vite打包
+vite打包
@@ -1,5 +0,0 @@
-console.log("这是第二个ts文件1");
-let a = 10;
-let b = 10;
-// document.getElementById
-console.log("这是第三个ts文件1");
-let c = 10;
-let d = 10;
@@ -0,0 +1,32 @@
+console.log("这是第二个ts文件1");
+let a;
+a = '12';
+a = undefined;
+console.log(a, 'a');
+function fn1(a, b) {
+ console.log(a + b);
+}
+fn1(1, '76');
+function fn2() {
+ console.log('fn2');
+fn2();
+console.log("这是第三个ts文件1");
+let c;
+c = 12;
+c = '1';
+let d = 10;
+console.log(c + d, 'x');
+let box = document.getElementById("box");
+box === null || box === void 0 ? void 0 : box.addEventListener('click', function () {
+ console.log('一个盒子');
+});
+console.log("今天天气真好");
+const age = 10;
+console.log(age, '年龄');
+define("mm", ["require", "exports"], function (require, exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.mm = void 0;
+ exports.mm = '妹妹';
@@ -6,6 +6,7 @@
<title>Document</title>
</head>
<body>
- <script src="./a.js"></script>
+ <!-- <div id="box"></div> -->
+ <script src="./dist/hello.js"></script>
</body>
</html>
@@ -1,5 +1,19 @@
+// import {mm} from './mm'
console.log("这是第二个ts文件1");
+// console.log(mm,'哈哈哈')
+console.log(a,'a')
+function fn1(a:any,b:any):any {
+ console.log(a+b);
+fn1(1,'76')
+function fn2():void {
+ // throw new Error('报错')
+ console.log('fn2')
+fn2()
+// let b = 10;
// document.getElementById
@@ -1,5 +1,13 @@
console.log("这是第三个ts文件1");
+c = '1'
let d = 10;
+console.log(c + d,'x')
+// document.getElementById
+// c='12';
+box?.addEventListener('click',function() {
+ console.log('一个盒子')
+})
@@ -0,0 +1,5 @@
+console.log("今天天气真好")
+// age = '20';
+
+console.log(age,'年龄');
@@ -0,0 +1,2 @@
+// 抛出:export default/function/const
+export const mm = '妹妹';
@@ -25,10 +25,31 @@
// 规定ts转成什么版本的js
"target": "ES6",
// 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'node18', 'nodenext', 'preserve
- "module": "ES2015",
+ "module": "amd",
// 规定可以使用哪些库
"lib": ["dom"],
// 规定编译后的文件位置
- "outDir": "./dist"
+ "outDir": "./dist",
+ // 将编译后的文件全部放在一个文件夹内
+ "outFile": "./dist/hello.js",
+ // 允许编译js文件
+ "allowJs": true,
+ // 检查js代码是否符合规范
+ "checkJs": true,
+ // 移除注释
+ "removeComments": true,
+ // 严格模式
+ // "strict": false
+ // 规定错误是否允许被编译
+ // "noEmitOnError": true,
+ // 规定文件是否允许被编译
+ // "noEmit":false,
+ // "alwaysStrict": true,
+ // 规定不允许使用any
+ "noImplicitAny": true,
+ // 规定不允许使用this
+ // "noImplicitThis": true,
+ // 检查元素是否为空
+ // "strictNullChecks": true
}
@@ -34,4 +34,4 @@
</script>
-</html>
+</html>