diff --git a/basicPage/button/button.vue b/basicPage/button/button.vue index 45a6e43..073b140 100644 --- a/basicPage/button/button.vue +++ b/basicPage/button/button.vue @@ -14,7 +14,7 @@ - 按钮 + 按钮 按钮 按钮 按钮 @@ -77,6 +77,11 @@ 按钮 + + + 防抖模式 + 节流模式 + @@ -97,6 +102,10 @@ } }, methods: { + say(msg){ + this.$tn.message.toast(msg) + }, + } } diff --git a/tuniao-ui/components/tn-button/tn-button.vue b/tuniao-ui/components/tn-button/tn-button.vue index 820ce2f..793f343 100644 --- a/tuniao-ui/components/tn-button/tn-button.vue +++ b/tuniao-ui/components/tn-button/tn-button.vue @@ -1,302 +1,348 @@ + .tn-btn { + position: relative; + display: inline-flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + line-height: 1; + text-align: center; + text-decoration: none; + overflow: visible; + transform: translate(0rpx, 0rpx); + // background-color: $tn-mai + border-radius: 12rpx; + // color: $tn-font-color; + margin: 0; + + &--plain { + background-color: transparent !important; + background-image: none; + + &.tn-round { + border-radius: 1000rpx !important; + } + } + } + \ No newline at end of file diff --git a/tuniao-ui/libs/function/applyEven.js b/tuniao-ui/libs/function/applyEven.js new file mode 100644 index 0000000..0176857 --- /dev/null +++ b/tuniao-ui/libs/function/applyEven.js @@ -0,0 +1,28 @@ +//防抖 +export function debounceFun(func, delay=500) { + //定时器 + let timer; + return function(...args) { + // 清除之前设置的定时器 + clearTimeout(timer); + timer = setTimeout(() => { + func.apply(this, args); + }, delay); + }; +} + +//节流 +export function throttleFun(func, delay=500) { + //定时器 + let timer = null; + return function(...args) { + if(!timer){ + timer = setTimeout(() => { + //执行前清空 + timer = null; + console.log("执行了") + func.apply(this, args); + }, delay); + } + }; +}