From 92c55d96796e9dc6929b8b9e236a3e92ab3ed08d Mon Sep 17 00:00:00 2001 From: duqingquan Date: Fri, 6 Sep 2024 17:16:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0vue=20uts=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E9=BB=98=E8=AE=A4=E5=80=BC=E6=B5=8B=E8=AF=95=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 11 +++- pages/SyntaxCase/defaultValueTest.vue | 65 +++++++++++++++++++++ pages/SyntaxCase/instanceTest.vue | 36 +++++++++++- pages/advance/advance.vue | 9 ++- uni_modules/uts-syntaxcase/utssdk/index.uts | 42 ++++++++++++- 5 files changed, 158 insertions(+), 5 deletions(-) create mode 100644 pages/SyntaxCase/defaultValueTest.vue diff --git a/pages.json b/pages.json index d2c1451..b5379b0 100644 --- a/pages.json +++ b/pages.json @@ -164,10 +164,17 @@ "enablePullDownRefresh": false } - } + }, + { + "path": "pages/SyntaxCase/defaultValueTest", + "style": { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + }, + // #endif // #ifdef APP - , { "path": "pages/SyntaxCase/utsAndroid", "style": { diff --git a/pages/SyntaxCase/defaultValueTest.vue b/pages/SyntaxCase/defaultValueTest.vue new file mode 100644 index 0000000..d4f63a6 --- /dev/null +++ b/pages/SyntaxCase/defaultValueTest.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/pages/SyntaxCase/instanceTest.vue b/pages/SyntaxCase/instanceTest.vue index 07c115e..7997790 100644 --- a/pages/SyntaxCase/instanceTest.vue +++ b/pages/SyntaxCase/instanceTest.vue @@ -2,6 +2,7 @@
{{ret}} +
@@ -11,7 +12,12 @@ User } from '@/uni_modules/uts-advance' - + import { + Scan, + Scan1, + Scan2, + myClass + } from "@/uni_modules/uts-syntaxcase"; export default { data() { @@ -21,6 +27,34 @@ }, methods: { + defaultValueTest() { + const myClassInit = new myClass(); + // 默认值测试 + if(Scan() != 60000){ + this.ret = "测试失败1" + } + if(Scan(100) != 100){ + this.ret = "测试失败2" + } + if(Scan1() != null){ + this.ret = "测试失败3" + } + if(Scan1(100) != 100){ + this.ret = "测试失败4" + } + let ret5 = Scan2() + if(ret5 != "null"){ + console.log(ret5) + this.ret = "测试失败5" + } + if(Scan2(100) != 100){ + this.ret = "测试失败6" + } + if(myClassInit.to('123') != 123){ + this.ret = "测试失败7" + } + }, + instanceCreate() { const user1 = new User("张三", 20); diff --git a/pages/advance/advance.vue b/pages/advance/advance.vue index 6298bf3..fc34fe2 100644 --- a/pages/advance/advance.vue +++ b/pages/advance/advance.vue @@ -116,10 +116,17 @@ }, { name: "参数传递示例", url: "SyntaxCase/paramTest" - },{ + }, + { name: "实例测试示例", url: "SyntaxCase/instanceTest" }, + // #ifdef UNI-APP-X + { + name: "默认值测试示例", + url: "SyntaxCase/defaultValueTest" + }, + // #endif { name: "混编测试示例", url: "SyntaxCase/MixNativeCode" diff --git a/uni_modules/uts-syntaxcase/utssdk/index.uts b/uni_modules/uts-syntaxcase/utssdk/index.uts index b9bc6bf..113a951 100644 --- a/uni_modules/uts-syntaxcase/utssdk/index.uts +++ b/uni_modules/uts-syntaxcase/utssdk/index.uts @@ -428,4 +428,44 @@ export class UTSActivityComponentCallback extends UniActivityComponentCallback { } } // #endif -// #endif \ No newline at end of file +// #endif + +export function Scan(timeMillis : Number = 60000):number { + console.log("Scan", timeMillis) + return timeMillis +} + +export function Scan1(timeMillis ?: Number):string { + console.log("Scan", timeMillis) + if(timeMillis == null){ + return "null" + } + return timeMillis.toString() +} + +export function Scan2(timeMillis ?: Number | null):string { + console.log("Scan", timeMillis) + if(timeMillis == null){ + return "null" + } + return timeMillis.toString() +} + +export class myClass { + constructor() { + + } + + to(name: String):string { + console.log(name); + return name + } + + to1(name?: String):string { + if(name == null){ + return "null" + } + console.log(name); + return name! + } +} \ No newline at end of file -- GitLab