vue-draggable-resizable 的基本使用模式(极简模型)

<vue-draggable-resizable
	@activated = "onActivated({index: index, index2: index2})"
	@dragging = "onDrag"
	@resizing = "onResize"
	@dragstop = "onDragStop({index: index, index2: index2})"
	@resizestop = "onResizeStop({index: index, index2: index2})"
	:key = "item2.id + '-' + index2"
	:grid = "[1,1]"
	:w = item2.width
	:h = item2.height
	:x = item2.x
	:y = item2.y
	:z = item2.z
	:parent = "true">
	<div
		v-if="item2.type == 'ui-text'"
		class="ui-richText">
		<p :style="{'line-height': item2.lineHeight + 'px'}">{{item2.content}}</p>
	</div>
	<div
		v-if="item2.type == 'ui-image'"
		class="ui-image">
		<img :src="item2.content" alt="" />
	</div>
</vue-draggable-resizable>
import VueDraggableResizable from 'vue-draggable-resizable'

export default {
  data () {
    return {
      // 拖拽缩放
      drag: false,
      width: 0,
      height: 0,
      x: 0,
      y: 0
    }
  },
  components: {
    VueDraggableResizable
  },
  methods: {
    onActivated: function(e){
      var that = this;
      var layout = that.layout[e.index].child[e.index2];

      that.x = layout.x
      that.y = layout.y
      that.width = layout.width
      that.height = layout.height
    },
    onDrag: function (x, y) {
      var that = this;

      that.x = x;
      that.y = y;
    },
    onResize: function (x, y, width, height) {
      var that = this;

      that.x = x
      that.y = y
      that.width = width
      that.height = height
    },
    onDragStop: function(e){
      var that = this;
      var layout = that.layout[e.index].child[e.index2];

      layout.x = that.x;
      layout.y = that.y;
    },
    onResizeStop: function(e){
      var that = this;
      var layout = that.layout[e.index].child[e.index2];

      layout.x = that.x;
      layout.y = that.y;
      layout.width = that.width;
      layout.height = that.height;
    }
  }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值