在类中定义两个实例方法
export class Demo {
constructor() { }
test1() : Promise<boolean> {
console.log('test1')
return Promise.resolve(true);
}
test2() : void {
console.log('test2')
}
}
export function test3() : Promise<boolean> {
console.log('test3')
return Promise.resolve(true);
}
在页面中调用:
import {
Demo,
test3
} from '@/uni_modules/promise-test'
let demo = null;
export default {
data() {
return {}
},
onLoad() {
demo = new Demo();
},
methods: {
handleTest1() {
demo.test1();
},
handleTest2() {
demo.test2();
},
handleTest3() {
test3();
}
}
}
shmily121314 (作者)
已上传,麻烦看一下
2024-10-11 17:27