diff --git a/pages.json b/pages.json index d2c14511549dccdb821c5e510d327b545b893adb..b5379b083e7726453e885a8701470d2b53d0753a 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 0000000000000000000000000000000000000000..d4f63a6d8f94b06c4ad4fb6b86a3d3ebba6fd64c --- /dev/null +++ b/pages/SyntaxCase/defaultValueTest.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/pages/SyntaxCase/instanceTest.vue b/pages/SyntaxCase/instanceTest.vue index 07c115e61bde222122ace9e97cbec9c1876d83e2..7997790e9f03eae66aa2744ec8715fdb2e8a75c9 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 6298bf36aaa7f43689de7ccf97e01cd79fc09346..fc34fe2ddac4d0fb39d195424a153049199501fb 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 b9bc6bf0ce8209866c9d9705f915b7b8953e2d67..113a951e7a60773d7ed6db588d68ba01ba4e87d8 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