Commit 43e12b02 by 姜雷

添加防抖按钮组件

parent 29c77fef
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
</form-area> </form-area>
<div slot="footer"> <div slot="footer">
<el-button <el-button
:debounce="300"
type="primary" type="primary"
@click="showMessage" @click="showMessage"
>确定</el-button> >确定</el-button>
...@@ -51,9 +52,8 @@ ...@@ -51,9 +52,8 @@
<script> <script>
import Vue from 'vue'; import Vue from 'vue';
import { Button, Input, Select, Option } from 'element-ui'; import { Input, Select, Option } from 'element-ui';
Vue.component(Button.name, Button);
Vue.component(Input.name, Input); Vue.component(Input.name, Input);
export default { export default {
...@@ -73,7 +73,7 @@ export default { ...@@ -73,7 +73,7 @@ export default {
done(); done();
}, },
showMessage() { showMessage() {
this.$message.info('123123'); console.log('outClick');
}, },
}, },
}; };
......
{ {
"name": "rym-element-ui", "name": "rym-element-ui",
"version": "0.1.8", "version": "0.1.28",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
...@@ -9560,7 +9560,6 @@ ...@@ -9560,7 +9560,6 @@
"version": "6.3.3", "version": "6.3.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz",
"integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==",
"dev": true,
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"element-ui": "^2.4.5", "element-ui": "^2.4.5",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"popmotion": "^8.5.5", "popmotion": "^8.5.5",
"rxjs": "^6.3.3",
"vue": "^2.5.21", "vue": "^2.5.21",
"vue-router": "^3.0.2", "vue-router": "^3.0.2",
"vuex": "^3.0.1" "vuex": "^3.0.1"
......
import { Button } from 'element-ui';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
export default {
name: 'el-button',
extends: Button,
props: {
debounce: { type: Number },
},
data() {
return {
subject: null,
};
},
created() {
if (this.debounce) {
const subject = new Subject();
subject.pipe(debounceTime(this.debounce)).subscribe({
next: e => this.$emit('click', e),
});
this.subject = subject;
}
},
methods: {
handleClick(e) {
if (this.debounce) {
this.subject.next(e);
} else {
this.$emit('click', e);
}
},
},
};
import Button from './Button';
export default Button;
...@@ -16,6 +16,7 @@ import FormLine from './components/FormLine/index'; ...@@ -16,6 +16,7 @@ import FormLine from './components/FormLine/index';
import FormItem from './components/FormItem/index'; import FormItem from './components/FormItem/index';
import Transfer from './components/Transfer/index'; import Transfer from './components/Transfer/index';
import Message from './components/Message/index'; import Message from './components/Message/index';
// import Button from './components/Button/index';
const install = Vue => { const install = Vue => {
// Layout // Layout
...@@ -35,6 +36,7 @@ const install = Vue => { ...@@ -35,6 +36,7 @@ const install = Vue => {
Vue.component(FormItem.name, FormItem); Vue.component(FormItem.name, FormItem);
Vue.component(Transfer.name, Transfer); Vue.component(Transfer.name, Transfer);
Vue.prototype.$message = Message; Vue.prototype.$message = Message;
// Vue.component(Button.name, Button);
// Element-ui // Element-ui
Vue.component(Select.name, Select); Vue.component(Select.name, Select);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment