<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-12-03 15:21
- 阅读:313
3 个回复
BFC
你好,动态调整组件的x,y值即可改变坐标, 从上述代码来看,通过改变viewX和viewY 变量就能控制位置。
chenchang6 (作者)
感谢,以使用其他方法解决
b***@163.com
你好作者,请问你最终是如何解决的,我也遇到了这个问题缩放后图片会偏移
2024-12-23 16:05
b***@163.com
大兄弟,要是看到麻烦回复下哈,这个问题卡了很久了
2024-12-23 20:24
1***@qq.com
已有的解决方案,B站搜索:BV195z2Y4Ehj