提交 92c55d96 编写于 作者: 杜庆泉's avatar 杜庆泉

增加vue uts 方法默认值测试示例

上级 66edb501
......@@ -164,10 +164,17 @@
"enablePullDownRefresh": false
}
},
{
"path": "pages/SyntaxCase/defaultValueTest",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
// #endif
// #ifdef APP
,
{
"path": "pages/SyntaxCase/utsAndroid",
"style": {
......
<template>
<view class="buttons">
<button @click="testClick">测试全部</button>
<text>{{testRet}}</text>
</view>
</template>
<script setup>
import {
Scan,
Scan1,
Scan2,
myClass
} from "@/uni_modules/uts-syntaxcase";
import { ref } from 'vue'
const myClassInit = new myClass();
let testRet = ref("1");
const testClick = function(){
testRet.value = "success"
// #ifdef APP-ANDROID
if(Scan() != 60000){
testRet = "error1"
console.log("error1")
}
if(Scan(100) != 100){
testRet = "error2"
console.log("error2")
}
// #endif
if(Scan1() != "null"){
testRet = "error3"
console.log("error3")
}
if(Scan1(100) != 100){
testRet = "error4"
console.log("error4")
}
if(Scan2() != "null"){
testRet = "error5"
console.log("error5")
}
if(Scan2(100) != 100){
testRet = "error6"
console.log("error6")
}
if(myClassInit.to('123') != "123"){
testRet = "error7"
console.log("error7")
}
}
</script>
<style lang="scss">
.buttons{
padding: 20rpx 20rpx 460rpx;
button{
margin-bottom: 20rpx;
font-size: 28rpx;
padding: 3px;
}
}
</style>
......@@ -2,6 +2,7 @@
<div>
{{ret}}
<button @click="instanceCreate">多实例创建测试</button>
<button @click="defaultValueTest">默认值测试</button>
</div>
</template>
......@@ -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);
......
......@@ -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"
......
......@@ -429,3 +429,43 @@ export class UTSActivityComponentCallback extends UniActivityComponentCallback {
}
// #endif
// #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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册