vue之自定义指令

作用: 让最后一个元素绝对定位并尾随倒数第二个元素

Vue.directive('absolute-after', {
  /**
   * @param {Node} el
   */
  inserted(el) {
    if (el.parentNode.childNodes.length >= 2 && el.parentNode.lastChild === el) {
      const pHeight = $(el).prev('*')
        .height();
      const pWidth = $(el).prev('*')
        .width();
      const cHeight = $(el).height();
      $(el).css({
        position: 'absolute',
        left: pWidth,
        top: (pHeight - cHeight) / 2,
      });
    }
  },
});

作用: v-dialogdragwidth: 弹窗宽度拖大 拖小

最后更新于

这有帮助吗?