From b4b4bc52d9c698acbe717712a3641f0b841a4a69 Mon Sep 17 00:00:00 2001 From: yurj26 <1816387074@qq.com> Date: Mon, 17 Jul 2023 17:53:37 +0800 Subject: [PATCH] fix: uvue error --- pages/advance/advance.uvue | 179 +++++++++++++++++++++---------------- 1 file changed, 102 insertions(+), 77 deletions(-) diff --git a/pages/advance/advance.uvue b/pages/advance/advance.uvue index ca9b91e..42bcc28 100644 --- a/pages/advance/advance.uvue +++ b/pages/advance/advance.uvue @@ -3,13 +3,14 @@ - + {{item.name}} - + {{page.name}} @@ -24,9 +25,22 @@ clearIntervalTask, playAssetAudio, getMetaConfig, - quitApp + quitApp, + TimerOptions } from "../../uni_modules/uts-advance"; + type Page = { + name : string, + url ?: string + function ?: string + } + type ListItem = { + name : string, + open : boolean, + pages : Page[], + } + + export default { data() { return { @@ -34,67 +48,65 @@ taskId: 0, list: [{ - name: "延迟任务", - open: false, - pages: [{ - name: "开启延迟任务", - function: "testTimer" - }] - }, - { - name: "定时任务", - open: false, - pages: [{ - name: "开启定时任务", - function: "testInterval" - }, { - name: "关闭定时任务", - function: "testClearInterval" - }] - }, - { - name: "语法示例", - open: false, - pages: [{ - name: "进阶语法示例", - url: "SyntaxCase/index" - }, { - name: "参数传递示例", - url: "SyntaxCase/paramTest" - },{ - name: "实例测试示例", - url: "SyntaxCase/instanceTest" - }] - }, - { - name: "日志打印", - open: false, - pages: [{ - name: "console示例", - url: "SyntaxCase/consoleTest" - }] - }, - { - name: "平台代码示例", - open: false, - pages: [{ - name: "UTSAndroid", - url: "SyntaxCase/utsAndroid" - }, { - name: "UTSiOS", - url: "SyntaxCase/utsiOS" - }] - }, - - - ], + name: "延迟任务", + open: false, + pages: [{ + name: "开启延迟任务", + function: "testTimer" + }] as Page[] + }, + { + name: "定时任务", + open: false, + pages: [{ + name: "开启定时任务", + function: "testInterval" + }, { + name: "关闭定时任务", + function: "testClearInterval" + }] as Page[] + }, + { + name: "语法示例", + open: false, + pages: [{ + name: "进阶语法示例", + url: "SyntaxCase/index" + }, { + name: "参数传递示例", + url: "SyntaxCase/paramTest" + }, { + name: "实例测试示例", + url: "SyntaxCase/instanceTest" + }] as Page[] + }, + { + name: "日志打印", + open: false, + pages: [{ + name: "console示例", + url: "SyntaxCase/consoleTest" + }] as Page[] + }, + { + name: "平台代码示例", + open: false, + pages: [{ + name: "UTSAndroid", + url: "SyntaxCase/utsAndroid" + }, { + name: "UTSiOS", + url: "SyntaxCase/utsiOS" + }] as Page[] + }, + ] as ListItem[], arrowUpIcon: '/static/icons/arrow-up.png', arrowDownIcon: '/static/icons/arrow-down.png', arrowRightIcon: '/static/icons/arrow-right.png', } }, methods: { - triggerCollapse(index) { + triggerCollapse(index : number) { for (var i = 0; i < this.list.length; ++i) { if (index == i) { this.list[i].open = !this.list[i].open; @@ -103,9 +115,20 @@ } } }, - goDetailPage(e) { - if (e.function) { - this[e.function]() + goDetailPage(e : Page) { + if (e.function != null) { + const funName = e.function + switch (funName) { + case 'testTimer': + this.testTimer() + break + case 'testInterval': + this.testInterval() + break + case 'testClearInterval': + this.testClearInterval() + break + } return } uni.navigateTo({ @@ -116,54 +139,56 @@ /** * 测试延迟任务 */ - testTimer: function() { + testTimer: function () { doTimerTask({ - start: function(response) { + start: function (response) { uni.showToast({ title: response, icon: 'none' }); }, - work: function(response) { + work: function (response) { uni.showToast({ title: response, icon: 'none' }); }, - }); + } as TimerOptions); }, /** * 测试周期任务 */ - testInterval: function() { + testInterval: function () { var ret = doIntervalTask({ - start: function(response) { + start: function (response) { uni.showToast({ title: response, icon: 'none' }); }, - work: function(response) { + work: function (response) { uni.showToast({ title: response, icon: 'none' }); }, - }); - this.taskId = ret.taskId; + } as TimerOptions); + if (ret.taskId != null) { + this.taskId = ret.taskId!; + } }, /** * 取消周期任务 */ - testClearInterval: function() { + testClearInterval: function () { console.log(this.taskId); clearIntervalTask(this.taskId); }, - testInputDialog() { - getUserInput(function(res) { - console.log(res); - }); - }, + // testInputDialog() { + // getUserInput(function (res) { + // console.log(res); + // }); + // }, testQuitApp() { quitApp() }, @@ -184,6 +209,6 @@ @import '@/common/uni-uvue.css'; .uni-container { - min-height: 100%; + /* min-height: 100%; */ } \ No newline at end of file -- GitLab