123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <template>
- <view class="submit-btn" @tap="$tools.throttle(submit)">
- <slot name="btns" v-bind:isSubmitted="isSubmitted"></slot>
- </view>
- </template>
- <script>
- export default {
- props: {
- isOnce:{
- type:Boolean,
- default:true
- }
- },
- data() {
- return {
- isSubmitted:false,
- }
- },
- beforeDestroy(){
- if(this.submitTimer){
- // console.log("beforeDestroy 销毁 this.timer--")
- clearTimeout(this.submitTimer);
- this.submitTimer = null;
- }
- },
- methods:{
- submit(){
- if(this.isSubmitted){
- return;
- }
- this.$emit("submit")
- },
- chgeStatus(){
- this.isSubmitted = true;
- if(!this.isOnce){
- this.submitTimer = setTimeout(()=>{
- // console.log("定时到---")
- this.isSubmitted = false;
- },3000)
- }
-
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- // .submit-btn{
- // opacity: 0.6;
- // }
- </style>
|