<movable-area :scale-area="true" :style="{ width: '100%', height: '100%', backgroundColor: 'red' }">
<movable-view
direction="all"
:inertia="false"
:scale="true"
:scale-value="scale"
:scale-min="0.5"
:scale-max="2"
:animation="true"
:style="{ width: '3000px', height: '3000px', backgroundColor: 'red' }"
@scale="scaleChange"
@change="change"
:x="viewX"
:y="viewY">
<view style="width: 1000%; height: 1000%; background-color: bisque">
<view style="width: 100rpx; height: 100rpx; position: fixed; top: 200px; left: 200px; background-color: red"></view>
</view>
</movable-view>
</movable-area>
==========================js==============================
scaleChange(e) {
let oldScale = (e.detail.scale - this.scale) * -1;
this.scale = e.detail.scale;
this.$nextTick(function () {
this.viewX = this.oldViewX * e.detail.scale;
this.viewY = this.oldViewY * e.detail.scale;
});
},
change(e) {
this.oldViewX = e.detail.x;
this.oldViewY = e.detail.y;
}
chenchang6
- 发布:2024-08-22 11:49
- 更新:2024-09-27 16:24
- 阅读:149
2 个回复
BFC
你好,动态调整组件的x,y值即可改变坐标, 从上述代码来看,通过改变viewX和viewY 变量就能控制位置。
chenchang6 (作者)
感谢,以使用其他方法解决