采用this.$uv.xxx方式使用api实现节流
This commit is contained in:
parent
30279799b5
commit
1d565c9531
15
main.js
15
main.js
|
|
@ -3,7 +3,13 @@ import App from './App'
|
||||||
// #ifndef VUE3
|
// #ifndef VUE3
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import './uni.promisify.adaptor'
|
import './uni.promisify.adaptor'
|
||||||
|
import uvUI from '@/uni_modules/uv-ui-tools'
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
// 全局安装 uvUI
|
||||||
|
Vue.use(uvUI)
|
||||||
|
|
||||||
App.mpType = 'app'
|
App.mpType = 'app'
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
...App,
|
...App,
|
||||||
|
|
@ -15,18 +21,23 @@ app.$mount()
|
||||||
import { createSSRApp } from 'vue'
|
import { createSSRApp } from 'vue'
|
||||||
import PageScrollMixin from './mixins/page-scroll-mixin.js'
|
import PageScrollMixin from './mixins/page-scroll-mixin.js'
|
||||||
import store from './store/index.js'
|
import store from './store/index.js'
|
||||||
|
import uvUI from '@/uni_modules/uv-ui-tools'
|
||||||
|
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
|
|
||||||
// 注册全局 mixin (Vue3 方式)
|
// 注册全局 mixin (Vue3 方式)
|
||||||
app.mixin(PageScrollMixin)
|
app.mixin(PageScrollMixin)
|
||||||
|
|
||||||
// 注册 store
|
// 注册 store
|
||||||
app.use(store)
|
app.use(store)
|
||||||
|
|
||||||
|
// Vue3 方式注册 uvUI
|
||||||
|
app.use(uvUI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
app,
|
app,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #endif
|
|
||||||
|
// #endif
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="main-content">
|
<view class="main-content">
|
||||||
<!-- 登录按钮 -->
|
<!-- 登录按钮 -->
|
||||||
<button :disabled="loginLoading" class="login-btn" @click="throttle()(goToLogin, 3000)">
|
<button :disabled="loginLoading" class="login-btn" @click="goToLogin">
|
||||||
<text class="btn-text">{{ loginLoading ? '登录中...' : '微信用户一键登录' }}</text>
|
<text class="btn-text">{{ loginLoading ? '登录中...' : '微信用户一键登录' }}</text>
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -84,8 +84,6 @@ import { getServiceTerms, getPrivacyPolicy } from '@/api/article/article.js'
|
||||||
import { commonEnum } from '../../enum/commonEnum'
|
import { commonEnum } from '../../enum/commonEnum'
|
||||||
import { getNavBarHeight, getTitleBarHeight } from '../../utils/system'
|
import { getNavBarHeight, getTitleBarHeight } from '../../utils/system'
|
||||||
|
|
||||||
import throttle from 'uview-ui/libs/function/throttle'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -254,6 +252,10 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
goToLogin() {
|
goToLogin() {
|
||||||
|
this.$uv.throttle(this.Login, 3000)
|
||||||
|
},
|
||||||
|
|
||||||
|
Login() {
|
||||||
console.log('开始登录流程')
|
console.log('开始登录流程')
|
||||||
|
|
||||||
// 显示加载状态
|
// 显示加载状态
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
mounted() {
|
||||||
|
console.log('uvUI 可用性:', !!this.$uv)
|
||||||
|
console.log('debounce 方法:', !!this.$uv?.debounce)
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentLocation: {},
|
currentLocation: {},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user