Commit 7aea9674 by liuyong

修改代码

1 parent 20db72b9
export default function initDirective(vue) {
/** 节流 */
vue.directive('throttle', {
inserted: function (el, binding) {
let stop = false;
el.addEventListener(binding.arg, (e) => {
if (stop) return;
binding.value(e)
stop = true;
setTimeout(() => {
stop = false
}, 500)
})
}
})
/** 防抖 */
vue.directive('debounce', {
inserted: function (el, binding) {
let stopTime;
el.addEventListener(binding.arg, (e) => {
clearTimeout(stopTime);
stopTime = setTimeout(binding.value, 1000, e)
})
}
})
}
......@@ -4,6 +4,9 @@ import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import initDirective from './directive';
initDirective(Vue);
Vue.config.productionTip = false;
......
......@@ -174,8 +174,8 @@
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button class="greenButton" @click="release_dialog">发布</el-button>
<el-button class="greenButton" @click="save_dialog">保存</el-button>
<el-button class="greenButton" v-debounce:click="release_dialog">发布</el-button>
<el-button class="greenButton" v-debounce:click="save_dialog">保存</el-button>
<el-button @click="add_dialog = false">取消</el-button>
</span>
</el-dialog>
......
......@@ -121,7 +121,7 @@
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button class="greenButton" @click="ok">确定</el-button>
<el-button class="greenButton" v-debounce:click="ok">确定</el-button>
<el-button @click="add_dialog = false">取消</el-button>
</span>
</el-dialog>
......
......@@ -92,7 +92,7 @@
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button class="greenButton" @click="ok">确定</el-button>
<el-button class="greenButton" v-debounce:click="ok">确定</el-button>
<el-button @click="add_dialog = false">取消</el-button>
</span>
</el-dialog>
......
......@@ -132,7 +132,7 @@
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button class="greenButton" @click="ok">确定</el-button>
<el-button class="greenButton" v-debounce:click="ok">确定</el-button>
<el-button @click="add_dialog = false">取消</el-button>
</span>
</el-dialog>
......
......@@ -130,7 +130,7 @@
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button class="greenButton" @click="ok">保存</el-button>
<el-button class="greenButton" v-debounce:click="ok">保存</el-button>
<el-button class="greenButton">编辑文档</el-button>
<el-button @click="add_dialog = false">取消</el-button>
</span>
......
......@@ -153,7 +153,7 @@
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button class="greenButton" @click="ok">确定</el-button>
<el-button class="greenButton" v-debounce:click="ok">确定</el-button>
<el-button @click="add_dialog = false">取消</el-button>
</span>
</el-dialog>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!