Browse Source

新增活动保证多次点击只执行一次(修改版)

Hongxilin
hongxilin 5 months ago
parent
commit
39c8282cc8
  1. 18
      vue/gold-system/src/views/managerecharge/activity.vue

18
vue/gold-system/src/views/managerecharge/activity.vue

@ -166,7 +166,21 @@ const add = async function () {
} }
}); });
}; };
const throttledAdd = _.throttle(add, 5000);
// 使 _.throttle trailing false
const throttledAdd = _.throttle(add, 5000, { trailing: false });
//
// let onceFunction = true;
//
// const throttledAdd = (...args) => {
// if (onceFunction) {
// add.apply(null, args);
// onceFunction = false; // false
// timer = setTimeout(() => {
// onceFunction = true; //
// timer = null;
// }, 1000); // 10001
// }
// };
// ========================================================= // =========================================================
// //
const del = function (row) { const del = function (row) {
@ -512,7 +526,7 @@ onMounted(async function () {
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click="closeAddActivityVisible">取消</el-button> <el-button @click="closeAddActivityVisible">取消</el-button>
<el-button type="primary" @click="throttledAdd()"> 提交 </el-button>
<el-button type="primary" @click="throttledAdd"> 提交 </el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>

Loading…
Cancel
Save