paramTest.vue 1.7 KB
Newer Older
杜庆泉's avatar
杜庆泉 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
<template>
	<button @click="inputArrayTest">传入数组参数</button>
	<button @click="inputParamTest">传入复杂对象参数</button>
	<button @click="returnArrayTest">返回数组参数</button>
	<button @click="returnParamTest">返回复杂对象参数</button>
	<button @click="callbackArrayTest">异步返回数组</button>
	<button @click="callbackParamTest">异步返回复杂对象</button>
</template>

<script>
	import {
		inputArray,
		inputParam,
		returnArray,
		returnParam,
		callbackArray,
		callbackParam
	} from '../../uni_modules/uts-advance'



	export default {
		data() {
			return {}
		},
		methods: {

			inputArrayTest() {
				let ret = inputArray(['a', 'b', 'c'])
				if (ret) {
					uni.showToast({
						title: '测试通过'
					})
				}
			},

			inputParamTest() {
				let ret = inputParam({
					title: "hello",
					array: [1, 2, 3]
				})
				if (ret) {
					uni.showToast({
						title: '测试通过'
					})
				}
			},
			returnArrayTest() {
				let ret = returnArray()
				if ('["1","2","3"]' == JSON.stringify(ret)) {
					uni.showToast({
						title: '测试通过'
					})
				}
			},
			returnParamTest() {
				let ret = returnParam()
				if ('{"title":"returnParam","array":["1","2","3"]}' == JSON.stringify(ret)) {
					uni.showToast({
						title: '测试通过'
					})
				}
			},

			callbackArrayTest() {
				callbackArray(function(res) {
					if ('["8","8","8"]' == JSON.stringify(res)) {
						uni.showToast({
							title: '测试通过'
						})
					}
				});

			},

			callbackParamTest() {
				callbackParam(function(res) {
					if ('{"title":"callbackParam","array":["4","5","6"]}' == JSON.stringify(res)) {
						uni.showToast({
							title: '测试通过'
						})
					}
				});
			}

		}
	}
</script>

<style>
</style>