Advance.vue 1.3 KB
Newer Older
杜庆泉's avatar
init  
杜庆泉 已提交
1
<template>
杜庆泉's avatar
杜庆泉 已提交
2 3 4 5 6 7 8 9
	<view>
		<page-head :title="title"></page-head>
			<view class="uni-btn-v uni-common-mt">
				<button type="primary"  @tap="testTimer">延迟任务</button>
				<button type="primary"  @tap="testInterval">定时任务</button>
				<button type="primary"  @tap="testClearInterval">关闭定时任务</button>
			</view>
	</view>
杜庆泉's avatar
init  
杜庆泉 已提交
10
</template>
杜庆泉's avatar
杜庆泉 已提交
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
<script>
	import {
	  doTimerTask,
	  doIntervalTask,
	} from "../../../uni_modules/uts-advance";
	
	export default {
		data() {
			return {
				title: 'UTS进阶示例',
				taskId:0
			}
		},
		onUnload:function(){
		},
		methods: {
			testTimer: function () {
				doTimerTask({
					start:function(response){
						uni.showToast({
							title:response,
							icon:'none'
						});
					},
					work:function(response){
						uni.showToast({
							title:response,
							icon:'none'
						});
					},
				});
			},
			testInterval: function () {
				var ret = doIntervalTask({
					start:function(response){
						uni.showToast({
							title:response,
							icon:'none'
						});
					},
					work:function(response){
						uni.showToast({
							title:response,
							icon:'none'
						});
					},
				});
				this.taskId = ret.taskId;
			},
			
			testClearInterval: function () {
				console.log(this.taskId);
			},
			
			
		}
	}
</script>
杜庆泉's avatar
init  
杜庆泉 已提交
69

杜庆泉's avatar
杜庆泉 已提交
70
<style>
杜庆泉's avatar
init  
杜庆泉 已提交
71

杜庆泉's avatar
杜庆泉 已提交
72 73
  
</style>