/**
 * v-clipboard 剪切板
 */
// import Vue from 'vue';
export default {
  bind(el, binding, vnode, oldVnode) {
    // let val = '';
    el.val = binding.value;
    el.handler = function() {
      const val = el.val;
      const input = document.createElement('input');
      el.appendChild(input);
      input.value = val;
      input.select();
      document.execCommand('Copy');
      el.__vue__.$tips({ type: 'success', message: '复制成功' });
      input.parentNode.removeChild(input);
    };
    el.addEventListener('click', el.handler);
  },
  update(el, binding, vnode, oldVnode) {
    el.val = binding.value;
  },
  unbind: function(el) {
    el.removeEventListener('click', el.handler);
  }
};
