crop.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <view class="container">
  3. <view class="page-body uni-content-info">
  4. <view class='cropper-content'>
  5. <view v-if="isShowImg" class="uni-corpper" :style="'width:'+cropperInitW+'px;height:'+cropperInitH+'px;background:#000'">
  6. <view class="uni-corpper-content" :style="'width:'+cropperW+'px;height:'+cropperH+'px;left:'+cropperL+'px;top:'+cropperT+'px'">
  7. <image :src="imageSrc" :style="'width:'+cropperW+'px;height:'+cropperH+'px'"></image>
  8. <view class="uni-corpper-crop-box" @touchstart.stop="contentStartMove" @touchmove.stop="contentMoveing" @touchend.stop="contentTouchEnd"
  9. :style="'left:'+cutL+'px;top:'+cutT+'px;right:'+cutR+'px;bottom:'+cutB+'px'">
  10. <view class="uni-cropper-view-box">
  11. <view class="uni-cropper-dashed-h"></view>
  12. <view class="uni-cropper-dashed-v"></view>
  13. <view class="uni-cropper-line-t" data-drag="top" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  14. <view class="uni-cropper-line-r" data-drag="right" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  15. <view class="uni-cropper-line-b" data-drag="bottom" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  16. <view class="uni-cropper-line-l" data-drag="left" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  17. <view class="uni-cropper-point point-t" data-drag="top" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  18. <view class="uni-cropper-point point-tr" data-drag="topTight"></view>
  19. <view class="uni-cropper-point point-r" data-drag="right" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  20. <view class="uni-cropper-point point-rb" data-drag="rightBottom" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  21. <view class="uni-cropper-point point-b" data-drag="bottom" @touchstart.stop="dragStart" @touchmove.stop="dragMove" @touchend.stop="dragEnd"></view>
  22. <view class="uni-cropper-point point-bl" data-drag="bottomLeft"></view>
  23. <view class="uni-cropper-point point-l" data-drag="left" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  24. <view class="uni-cropper-point point-lt" data-drag="leftTop"></view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class='cropper-config'>
  31. <button type="primary reverse" @click="getImage" style='margin-top: 30rpx;'> 选择图片 </button>
  32. <button type="warn" @click="getImageInfo" style='margin-top: 30rpx;'> 点击生成图片 </button>
  33. </view>
  34. <canvas canvas-id="myCanvas" :style="'position:absolute;border: 1px solid red; width:'+imageW+'px;height:'+imageH+'px;top:-9999px;left:-9999px;'"></canvas>
  35. </view>
  36. <page-foot :name="name"></page-foot>
  37. </view>
  38. </template>
  39. <script>
  40. let sysInfo = uni.getSystemInfoSync();
  41. let SCREEN_WIDTH = sysInfo.screenWidth
  42. let PAGE_X, // 手按下的x位置
  43. PAGE_Y, // 手按下y的位置
  44. PR = sysInfo.pixelRatio, // dpi
  45. T_PAGE_X, // 手移动的时候x的位置
  46. T_PAGE_Y, // 手移动的时候Y的位置
  47. CUT_L, // 初始化拖拽元素的left值
  48. CUT_T, // 初始化拖拽元素的top值
  49. CUT_R, // 初始化拖拽元素的
  50. CUT_B, // 初始化拖拽元素的
  51. CUT_W, // 初始化拖拽元素的宽度
  52. CUT_H, // 初始化拖拽元素的高度
  53. IMG_RATIO, // 图片比例
  54. IMG_REAL_W, // 图片实际的宽度
  55. IMG_REAL_H, // 图片实际的高度
  56. DRAFG_MOVE_RATIO = 1, //移动时候的比例,
  57. INIT_DRAG_POSITION = 100, // 初始化屏幕宽度和裁剪区域的宽度之差,用于设置初始化裁剪的宽度
  58. DRAW_IMAGE_W = sysInfo.screenWidth // 设置生成的图片宽度
  59. export default {
  60. /**
  61. * 页面的初始数据
  62. */
  63. data() {
  64. return {
  65. name:'杨大宝',
  66. imageSrc: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b31d90c0-5168-11eb-bdc1-8bd33eb6adaa.jpg',
  67. isShowImg: false,
  68. // 初始化的宽高
  69. cropperInitW: SCREEN_WIDTH,
  70. cropperInitH: SCREEN_WIDTH,
  71. // 动态的宽高
  72. cropperW: SCREEN_WIDTH,
  73. cropperH: SCREEN_WIDTH,
  74. // 动态的left top值
  75. cropperL: 0,
  76. cropperT: 0,
  77. transL: 0,
  78. transT: 0,
  79. // 图片缩放值
  80. scaleP: 0,
  81. imageW: 0,
  82. imageH: 0,
  83. // 裁剪框 宽高
  84. cutL: 0,
  85. cutT: 0,
  86. cutB: SCREEN_WIDTH,
  87. cutR: '100%',
  88. qualityWidth: DRAW_IMAGE_W,
  89. innerAspectRadio: DRAFG_MOVE_RATIO
  90. }
  91. },
  92. /**
  93. * 生命周期函数--监听页面加载
  94. */
  95. onLoad: function (options) {},
  96. /**
  97. * 生命周期函数--监听页面初次渲染完成
  98. */
  99. onReady: function () {
  100. this.loadImage();
  101. },
  102. methods: {
  103. setData: function (obj) {
  104. let that = this;
  105. Object.keys(obj).forEach(function (key) {
  106. that.$set(that.$data, key, obj[key])
  107. });
  108. },
  109. getImage: function () {
  110. var _this = this
  111. uni.chooseImage({
  112. success: function (res) {
  113. _this.setData({
  114. imageSrc: res.tempFilePaths[0],
  115. })
  116. _this.loadImage();
  117. },
  118. })
  119. },
  120. loadImage: function () {
  121. var _this = this
  122. uni.showLoading({
  123. title: '图片加载中...',
  124. })
  125. uni.getImageInfo({
  126. src: _this.imageSrc,
  127. success: function success(res) {
  128. IMG_RATIO = res.width / res.height
  129. if (IMG_RATIO >= 1) {
  130. IMG_REAL_W = SCREEN_WIDTH
  131. IMG_REAL_H = SCREEN_WIDTH / IMG_RATIO
  132. } else {
  133. IMG_REAL_W = SCREEN_WIDTH * IMG_RATIO
  134. IMG_REAL_H = SCREEN_WIDTH
  135. }
  136. let minRange = IMG_REAL_W > IMG_REAL_H ? IMG_REAL_W : IMG_REAL_H
  137. INIT_DRAG_POSITION = minRange > INIT_DRAG_POSITION ? INIT_DRAG_POSITION : minRange
  138. // 根据图片的宽高显示不同的效果 保证图片可以正常显示
  139. if (IMG_RATIO >= 1) {
  140. let cutT = Math.ceil((SCREEN_WIDTH / IMG_RATIO - (SCREEN_WIDTH / IMG_RATIO - INIT_DRAG_POSITION)) / 2);
  141. let cutB = cutT;
  142. let cutL = Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH + INIT_DRAG_POSITION) / 2);
  143. let cutR = cutL;
  144. _this.setData({
  145. cropperW: SCREEN_WIDTH,
  146. cropperH: SCREEN_WIDTH / IMG_RATIO,
  147. // 初始化left right
  148. cropperL: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH) / 2),
  149. cropperT: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH / IMG_RATIO) / 2),
  150. cutL: cutL,
  151. cutT: cutT,
  152. cutR: cutR,
  153. cutB: cutB,
  154. // 图片缩放值
  155. imageW: IMG_REAL_W,
  156. imageH: IMG_REAL_H,
  157. scaleP: IMG_REAL_W / SCREEN_WIDTH,
  158. qualityWidth: DRAW_IMAGE_W,
  159. innerAspectRadio: IMG_RATIO
  160. })
  161. } else {
  162. let cutL = Math.ceil((SCREEN_WIDTH * IMG_RATIO - (SCREEN_WIDTH * IMG_RATIO)) / 2);
  163. let cutR = cutL;
  164. let cutT = Math.ceil((SCREEN_WIDTH - INIT_DRAG_POSITION) / 2);
  165. let cutB = cutT;
  166. _this.setData({
  167. cropperW: SCREEN_WIDTH * IMG_RATIO,
  168. cropperH: SCREEN_WIDTH,
  169. // 初始化left right
  170. cropperL: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH * IMG_RATIO) / 2),
  171. cropperT: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH) / 2),
  172. cutL: cutL,
  173. cutT: cutT,
  174. cutR: cutR,
  175. cutB: cutB,
  176. // 图片缩放值
  177. imageW: IMG_REAL_W,
  178. imageH: IMG_REAL_H,
  179. scaleP: IMG_REAL_W / SCREEN_WIDTH,
  180. qualityWidth: DRAW_IMAGE_W,
  181. innerAspectRadio: IMG_RATIO
  182. })
  183. }
  184. _this.setData({
  185. isShowImg: true
  186. })
  187. uni.hideLoading()
  188. }
  189. })
  190. },
  191. // 拖动时候触发的touchStart事件
  192. contentStartMove(e) {
  193. PAGE_X = e.touches[0].pageX
  194. PAGE_Y = e.touches[0].pageY
  195. },
  196. // 拖动时候触发的touchMove事件
  197. contentMoveing(e) {
  198. var _this = this
  199. var dragLengthX = (PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
  200. var dragLengthY = (PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
  201. // 左移
  202. if (dragLengthX > 0) {
  203. if (this.cutL - dragLengthX < 0) dragLengthX = this.cutL
  204. } else {
  205. if (this.cutR + dragLengthX < 0) dragLengthX = -this.cutR
  206. }
  207. if (dragLengthY > 0) {
  208. if (this.cutT - dragLengthY < 0) dragLengthY = this.cutT
  209. } else {
  210. if (this.cutB + dragLengthY < 0) dragLengthY = -this.cutB
  211. }
  212. this.setData({
  213. cutL: this.cutL - dragLengthX,
  214. cutT: this.cutT - dragLengthY,
  215. cutR: this.cutR + dragLengthX,
  216. cutB: this.cutB + dragLengthY
  217. })
  218. PAGE_X = e.touches[0].pageX
  219. PAGE_Y = e.touches[0].pageY
  220. },
  221. contentTouchEnd() {
  222. },
  223. // 获取图片
  224. getImageInfo() {
  225. var _this = this;
  226. uni.showLoading({
  227. title: '图片生成中...',
  228. });
  229. // 将图片写入画布
  230. const ctx = uni.createCanvasContext('myCanvas');
  231. ctx.drawImage(_this.imageSrc, 0, 0, IMG_REAL_W, IMG_REAL_H);
  232. ctx.draw(true, () => {
  233. // 获取画布要裁剪的位置和宽度 均为百分比 * 画布中图片的宽度 保证了在微信小程序中裁剪的图片模糊 位置不对的问题 canvasT = (_this.cutT / _this.cropperH) * (_this.imageH / pixelRatio)
  234. var canvasW = ((_this.cropperW - _this.cutL - _this.cutR) / _this.cropperW) * IMG_REAL_W;
  235. var canvasH = ((_this.cropperH - _this.cutT - _this.cutB) / _this.cropperH) * IMG_REAL_H;
  236. var canvasL = (_this.cutL / _this.cropperW) * IMG_REAL_W;
  237. var canvasT = (_this.cutT / _this.cropperH) * IMG_REAL_H;
  238. uni.canvasToTempFilePath({
  239. x: canvasL,
  240. y: canvasT,
  241. width: canvasW,
  242. height: canvasH,
  243. destWidth: canvasW,
  244. destHeight: canvasH,
  245. quality: 0.5,
  246. canvasId: 'myCanvas',
  247. success: function (res) {
  248. uni.hideLoading()
  249. // 成功获得地址的地方
  250. uni.previewImage({
  251. current: '', // 当前显示图片的http链接
  252. urls: [res.tempFilePath] // 需要预览的图片http链接列表
  253. })
  254. }
  255. });
  256. });
  257. },
  258. // 设置大小的时候触发的touchStart事件
  259. dragStart(e) {
  260. T_PAGE_X = e.touches[0].pageX
  261. T_PAGE_Y = e.touches[0].pageY
  262. CUT_L = this.cutL
  263. CUT_R = this.cutR
  264. CUT_B = this.cutB
  265. CUT_T = this.cutT
  266. },
  267. // 设置大小的时候触发的touchMove事件
  268. dragMove(e) {
  269. var _this = this
  270. var dragType = e.target.dataset.drag
  271. switch (dragType) {
  272. case 'right':
  273. var dragLength = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
  274. if (CUT_R + dragLength < 0) dragLength = -CUT_R
  275. this.setData({
  276. cutR: CUT_R + dragLength
  277. })
  278. break;
  279. case 'left':
  280. var dragLength = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
  281. if (CUT_L - dragLength < 0) dragLength = CUT_L
  282. if ((CUT_L - dragLength) > (this.cropperW - this.cutR)) dragLength = CUT_L - (this.cropperW - this.cutR)
  283. this.setData({
  284. cutL: CUT_L - dragLength
  285. })
  286. break;
  287. case 'top':
  288. var dragLength = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
  289. if (CUT_T - dragLength < 0) dragLength = CUT_T
  290. if ((CUT_T - dragLength) > (this.cropperH - this.cutB)) dragLength = CUT_T - (this.cropperH - this.cutB)
  291. this.setData({
  292. cutT: CUT_T - dragLength
  293. })
  294. break;
  295. case 'bottom':
  296. var dragLength = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
  297. if (CUT_B + dragLength < 0) dragLength = -CUT_B
  298. this.setData({
  299. cutB: CUT_B + dragLength
  300. })
  301. break;
  302. case 'rightBottom':
  303. var dragLengthX = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
  304. var dragLengthY = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
  305. if (CUT_B + dragLengthY < 0) dragLengthY = -CUT_B
  306. if (CUT_R + dragLengthX < 0) dragLengthX = -CUT_R
  307. let cutB = CUT_B + dragLengthY;
  308. let cutR = CUT_R + dragLengthX;
  309. this.setData({
  310. cutB: cutB,
  311. cutR: cutR
  312. })
  313. break;
  314. default:
  315. break;
  316. }
  317. }
  318. }
  319. }
  320. </script>
  321. <style>
  322. /* pages/uni-cropper/index.wxss */
  323. .uni-content-info {
  324. /* position: fixed;
  325. top: 0;
  326. left: 0;
  327. right: 0;
  328. bottom: 0;
  329. display: block;
  330. align-items: center;
  331. flex-direction: column; */
  332. }
  333. .cropper-config {
  334. padding: 20rpx 40rpx;
  335. }
  336. .cropper-content {
  337. min-height: 750rpx;
  338. width: 100%;
  339. }
  340. .uni-corpper {
  341. position: relative;
  342. overflow: hidden;
  343. -webkit-user-select: none;
  344. -moz-user-select: none;
  345. -ms-user-select: none;
  346. user-select: none;
  347. -webkit-tap-highlight-color: transparent;
  348. -webkit-touch-callout: none;
  349. box-sizing: border-box;
  350. }
  351. .uni-corpper-content {
  352. position: relative;
  353. }
  354. .uni-corpper-content image {
  355. display: block;
  356. width: 100%;
  357. min-width: 0 !important;
  358. max-width: none !important;
  359. height: 100%;
  360. min-height: 0 !important;
  361. max-height: none !important;
  362. image-orientation: 0deg !important;
  363. margin: 0 auto;
  364. }
  365. /* 移动图片效果 */
  366. .uni-cropper-drag-box {
  367. position: absolute;
  368. top: 0;
  369. right: 0;
  370. bottom: 0;
  371. left: 0;
  372. cursor: move;
  373. background: rgba(0, 0, 0, 0.6);
  374. z-index: 1;
  375. }
  376. /* 内部的信息 */
  377. .uni-corpper-crop-box {
  378. position: absolute;
  379. background: rgba(255, 255, 255, 0.3);
  380. z-index: 2;
  381. }
  382. .uni-corpper-crop-box .uni-cropper-view-box {
  383. position: relative;
  384. display: block;
  385. width: 100%;
  386. height: 100%;
  387. overflow: visible;
  388. outline: 1rpx solid #69f;
  389. outline-color: rgba(102, 153, 255, .75)
  390. }
  391. /* 横向虚线 */
  392. .uni-cropper-dashed-h {
  393. position: absolute;
  394. top: 33.33333333%;
  395. left: 0;
  396. width: 100%;
  397. height: 33.33333333%;
  398. border-top: 1rpx dashed rgba(255, 255, 255, 0.5);
  399. border-bottom: 1rpx dashed rgba(255, 255, 255, 0.5);
  400. }
  401. /* 纵向虚线 */
  402. .uni-cropper-dashed-v {
  403. position: absolute;
  404. left: 33.33333333%;
  405. top: 0;
  406. width: 33.33333333%;
  407. height: 100%;
  408. border-left: 1rpx dashed rgba(255, 255, 255, 0.5);
  409. border-right: 1rpx dashed rgba(255, 255, 255, 0.5);
  410. }
  411. /* 四个方向的线 为了之后的拖动事件*/
  412. .uni-cropper-line-t {
  413. position: absolute;
  414. display: block;
  415. width: 100%;
  416. background-color: #69f;
  417. top: 0;
  418. left: 0;
  419. height: 1rpx;
  420. opacity: 0.1;
  421. cursor: n-resize;
  422. }
  423. .uni-cropper-line-t::before {
  424. content: '';
  425. position: absolute;
  426. top: 50%;
  427. right: 0rpx;
  428. width: 100%;
  429. -webkit-transform: translate3d(0, -50%, 0);
  430. transform: translate3d(0, -50%, 0);
  431. bottom: 0;
  432. height: 41rpx;
  433. background: transparent;
  434. z-index: 11;
  435. }
  436. .uni-cropper-line-r {
  437. position: absolute;
  438. display: block;
  439. background-color: #69f;
  440. top: 0;
  441. right: 0rpx;
  442. width: 1rpx;
  443. opacity: 0.1;
  444. height: 100%;
  445. cursor: e-resize;
  446. }
  447. .uni-cropper-line-r::before {
  448. content: '';
  449. position: absolute;
  450. top: 0;
  451. left: 50%;
  452. width: 41rpx;
  453. -webkit-transform: translate3d(-50%, 0, 0);
  454. transform: translate3d(-50%, 0, 0);
  455. bottom: 0;
  456. height: 100%;
  457. background: transparent;
  458. z-index: 11;
  459. }
  460. .uni-cropper-line-b {
  461. position: absolute;
  462. display: block;
  463. width: 100%;
  464. background-color: #69f;
  465. bottom: 0;
  466. left: 0;
  467. height: 1rpx;
  468. opacity: 0.1;
  469. cursor: s-resize;
  470. }
  471. .uni-cropper-line-b::before {
  472. content: '';
  473. position: absolute;
  474. top: 50%;
  475. right: 0rpx;
  476. width: 100%;
  477. -webkit-transform: translate3d(0, -50%, 0);
  478. transform: translate3d(0, -50%, 0);
  479. bottom: 0;
  480. height: 41rpx;
  481. background: transparent;
  482. z-index: 11;
  483. }
  484. .uni-cropper-line-l {
  485. position: absolute;
  486. display: block;
  487. background-color: #69f;
  488. top: 0;
  489. left: 0;
  490. width: 1rpx;
  491. opacity: 0.1;
  492. height: 100%;
  493. cursor: w-resize;
  494. }
  495. .uni-cropper-line-l::before {
  496. content: '';
  497. position: absolute;
  498. top: 0;
  499. left: 50%;
  500. width: 41rpx;
  501. -webkit-transform: translate3d(-50%, 0, 0);
  502. transform: translate3d(-50%, 0, 0);
  503. bottom: 0;
  504. height: 100%;
  505. background: transparent;
  506. z-index: 11;
  507. }
  508. .uni-cropper-point {
  509. width: 5rpx;
  510. height: 5rpx;
  511. background-color: #69f;
  512. opacity: .75;
  513. position: absolute;
  514. z-index: 3;
  515. }
  516. .point-t {
  517. top: -3rpx;
  518. left: 50%;
  519. margin-left: -3rpx;
  520. cursor: n-resize;
  521. }
  522. .point-tr {
  523. top: -3rpx;
  524. left: 100%;
  525. margin-left: -3rpx;
  526. cursor: n-resize;
  527. }
  528. .point-r {
  529. top: 50%;
  530. left: 100%;
  531. margin-left: -3rpx;
  532. margin-top: -3rpx;
  533. cursor: n-resize;
  534. }
  535. .point-rb {
  536. left: 100%;
  537. top: 100%;
  538. -webkit-transform: translate3d(-50%, -50%, 0);
  539. transform: translate3d(-50%, -50%, 0);
  540. cursor: n-resize;
  541. width: 36rpx;
  542. height: 36rpx;
  543. background-color: #69f;
  544. position: absolute;
  545. z-index: 1112;
  546. opacity: 1;
  547. }
  548. .point-b {
  549. left: 50%;
  550. top: 100%;
  551. margin-left: -3rpx;
  552. margin-top: -3rpx;
  553. cursor: n-resize;
  554. }
  555. .point-bl {
  556. left: 0%;
  557. top: 100%;
  558. margin-left: -3rpx;
  559. margin-top: -3rpx;
  560. cursor: n-resize;
  561. }
  562. .point-l {
  563. left: 0%;
  564. top: 50%;
  565. margin-left: -3rpx;
  566. margin-top: -3rpx;
  567. cursor: n-resize;
  568. }
  569. .point-lt {
  570. left: 0%;
  571. top: 0%;
  572. margin-left: -3rpx;
  573. margin-top: -3rpx;
  574. cursor: n-resize;
  575. }
  576. /* 裁剪框预览内容 */
  577. .uni-cropper-viewer {
  578. position: relative;
  579. width: 100%;
  580. height: 100%;
  581. overflow: hidden;
  582. }
  583. .uni-cropper-viewer image {
  584. position: absolute;
  585. z-index: 2;
  586. }
  587. </style>