欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue3 中使用vue?img?cutter?圖片裁剪插件的方法

 更新時間:2024年05月08日 10:05:51   作者:yqcoder  
這篇文章主要介紹了vue3 中使用vue?img?cutter?圖片裁剪插件的方法,首先安裝依賴,構(gòu)建 components/ImgCutter.vue 組件,需要的朋友可以參考下

前言:vue-img-cutter 文檔,本文檔主要講解插件在 vue3 中使用。

一:安裝依賴

npm install vue-img-cutter
# or
yarn add vue-img-cutter
# or
pnpm add vue-img-cutter

二:構(gòu)建 components/ImgCutter.vue 組件

<script setup lang="ts">
  import ImgCutter from "vue-img-cutter";
  import { updateAvatar } from "@/api/user.ts";
  let emits = defineEmits(["getUrl"]);
  let cutDown = (data: any) => {
    let formData = new FormData();
    let { file } = data;
    formData.append("file", file);
    updateAvatar(formData).then((res) => {
      emits("getUrl", res);
    });
  };
</script>
<template>
  <ImgCutter @cutDown="cutDown"></ImgCutter>
</template>
<style lang="scss" scoped></style>

三:使用組件

<script setup lang="ts">
  import ImgCutter from "@/components/ImgCutter.vue";
  const getUrl = (str: any) => {
    console.log(1, str);
  };
</script>
<template>
  <div class="index">
    <ImgCutter @getUrl="getUrl" />
  </div>
</template>

四:參數(shù)

1. isModal

是否為彈窗模式,默認(rèn) true

<ImgCutter :isModal="true" />

2. showChooseBtn

是否顯示選擇圖片按鈕,默認(rèn) true

<ImgCutter :showChooseBtn="true" />

3. lockScroll

是否在 Dialog 出現(xiàn)時將 body 滾動鎖定,默認(rèn) true

<ImgCutter :lockScroll="true" />

4. label

默認(rèn)打開裁剪工具按鈕的顯示文字,默認(rèn) “選擇圖片”

<ImgCutter label="選擇圖片" />

5. boxWidth

裁剪工具寬度,默認(rèn) 800

<ImgCutter :boxWidth="800" />

6. boxHeight

裁剪工具高度,默認(rèn) 400

<ImgCutter :boxHeight="400" />

7. cutWidth

默認(rèn)裁剪寬度,默認(rèn) 200

<ImgCutter :cutWidth="200" />

8. cutHeight

默認(rèn)裁剪高度,默認(rèn) 200

<ImgCutter :cutHeight="200" />

9. tool

是否顯示工具欄,默認(rèn) true

<ImgCutter :tool="true" />

10. toolBgc

工具欄背景色,默認(rèn) #fff

<ImgCutter toolBgc="#fff" />

11. sizeChange

是否能夠調(diào)整裁剪框大小,默認(rèn) true

<ImgCutter :sizeChange="true" />

12. moveAble

能否調(diào)整裁剪區(qū)域位置,默認(rèn) true

<ImgCutter :moveAble="true" />

13. imgMove

能否拖動圖片,默認(rèn) true

<ImgCutter :imgMove="true" />

14. originalGraph

是否直接裁剪原圖,默認(rèn) false

<ImgCutter :originalGraph="false" />

15. crossOrigin

是否設(shè)置跨域,需要服務(wù)器做相應(yīng)更改,默認(rèn) false

<ImgCutter :crossOrigin="false" />

16. crossOriginHeader

設(shè)置跨域信息 crossOrigin 為 true 時才生效

<ImgCutter :crossOrigin="true" crossOriginHeader="" />

17. rate

圖片比例,例:"4:3"

<ImgCutter rate="4:3" />

18. WatermarkText

水印文字

<ImgCutter WatermarkText="水印" />

19. WatermarkTextFont

水印文字字體,默認(rèn) "12px Sans-serif"

<ImgCutter WatermarkTextFont="12px Sans-serif" />

20. WatermarkTextColor

水印文字顏色,默認(rèn) '#fff'

<ImgCutter WatermarkTextColor="#fff" />

21. WatermarkTextX

水印文字水平位置,默認(rèn) 0.95

<ImgCutter :WatermarkTextX="0.95" />

22. WatermarkTextY

水印文字垂直位置,默認(rèn) 0.95

<ImgCutter :WatermarkTextY="0.95" />

23. smallToUpload

如果裁剪尺寸固定且圖片尺寸小于裁剪尺寸則不裁剪直接返回文件,默認(rèn) false

<ImgCutter :smallToUpload="false" />

24. saveCutPosition

是否保存上一次裁剪位置及大小,默認(rèn) false

<ImgCutter :saveCutPosition="false" />

25. scaleAble

是否允許滾輪縮放圖片,默認(rèn) true

<ImgCutter :scaleAble="true" />

26. toolBoxOverflow

是否允許裁剪框超出圖片范圍,默認(rèn) true

<ImgCutter :toolBoxOverflow="true" />

27. index

自定義參數(shù),將會同結(jié)果一起返回,默認(rèn) null

<ImgCutter index="aaaa" />

28. previewMode

裁剪過程中是否返回裁剪結(jié)果,如果裁剪出現(xiàn)卡頓時將此項設(shè)置為 false,默認(rèn) true

<ImgCutter :previewMode="true" />

29. fileType

返回的文件類型 ( png / jpeg / webp),默認(rèn) png

<ImgCutter fileType="png" />

30. quality

圖像質(zhì)量,默認(rèn) 1

<ImgCutter :quality="1" />

31. accept

圖片類型,默認(rèn) 'image/gif, image/jpeg ,image/png'

<ImgCutter accept="image/gif, image/jpeg ,image/png" />

五:鉤子函數(shù)

1. cutDown

完成截圖后要執(zhí)行的方法,返回值:Object

<ImgCutter @cutDown="cutDown" />

2. error

錯誤回調(diào),返回值:Error object

<ImgCutter @error="error" />

3. onChooseImg

選擇圖片后,返回值:Object

<ImgCutter @onChooseImg="onChooseImg" />

4. onPrintImg

在畫布上繪制圖片,返回值:Object

<ImgCutter @onPrintImg="onPrintImg" />

5. onClearAll

清空畫布,返回值:null

<ImgCutter @onClearAll="onClearAll" />

六:插槽

1. open 或 openImgCutter

彈出裁剪框

<ImgCutter>
  <template #open> 選擇圖片 </template>
</ImgCutter>

2. choose

選擇本地圖片

<ImgCutter>
  <template #choose> 選擇圖片 </template>
</ImgCutter>

3. cancel

取消/清空

<ImgCutter>
  <template #cancel> 取消 </template>
</ImgCutter>

4. confirm

確認(rèn)裁剪

<ImgCutter>
  <template #confirm> 確認(rèn)裁剪 </template>
</ImgCutter>

5. ratio

工具欄:寬高比

<ImgCutter>
  <template #ratio> 工具欄:寬高比 </template>
</ImgCutter>

6. scaleReset

工具欄:重置縮放

<ImgCutter>
  <template #scaleReset> 取消 </template>
</ImgCutter>

7. turnLeft

工具欄:向左旋轉(zhuǎn)

<ImgCutter>
  <template #turnLeft> 工具欄:向左旋轉(zhuǎn) </template>
</ImgCutter>

8. turnRight

工具欄:向右旋轉(zhuǎn)

<ImgCutter>
  <template #turnRight> 工具欄:向右旋轉(zhuǎn) </template>
</ImgCutter>

9. reset

工具欄:重置旋轉(zhuǎn)

<ImgCutter>
  <template #reset> 工具欄:重置旋轉(zhuǎn) </template>
</ImgCutter>

10. flipHorizontal

工具欄:水平翻轉(zhuǎn)

<ImgCutter>
  <template #flipHorizontal> 工具欄:水平翻轉(zhuǎn) </template>
</ImgCutter>

11. flipVertically

工具欄:重置旋轉(zhuǎn)

<ImgCutter>
  <template #flipVertically> 工具欄:垂直翻轉(zhuǎn) </template>
</ImgCutter>

到此這篇關(guān)于vue img cutter 圖片裁剪詳解的文章就介紹到這了,更多相關(guān)vue img cutter裁剪內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue過濾器與內(nèi)置指令和自定義指令及組件使用詳解

    Vue過濾器與內(nèi)置指令和自定義指令及組件使用詳解

    這篇文章主要介紹了Vue過濾器與內(nèi)置指令和自定義指令及組件使用方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-12-12
  • Vue 瑩石攝像頭直播視頻實例代碼

    Vue 瑩石攝像頭直播視頻實例代碼

    本文通過實例代碼給大家介紹了vue 瑩石攝像頭直播視頻功能,文章還給大家提到了vue h5項目調(diào)用手機(jī)攝像頭錄像并上傳的功能,需要的朋友可以參考下
    2018-08-08
  • vue-mounted中如何處理data數(shù)據(jù)

    vue-mounted中如何處理data數(shù)據(jù)

    這篇文章主要介紹了vue-mounted中如何處理data數(shù)據(jù)方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • 對vue中的事件穿透與禁止穿透實例詳解

    對vue中的事件穿透與禁止穿透實例詳解

    今天小編就為大家分享一篇對vue中的事件穿透與禁止穿透實例詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-10-10
  • 詳解如何在Vue中使用Bootstrap

    詳解如何在Vue中使用Bootstrap

    在Vue中使用Bootstrap是常見的前端開發(fā)實踐之一,結(jié)合了Vue的響應(yīng)式數(shù)據(jù)綁定與Bootstrap的UI組件和布局系統(tǒng),能夠快速實現(xiàn)現(xiàn)代化的網(wǎng)頁應(yīng)用,本文將詳細(xì)介紹如何在Vue中使用Bootstrap,從安裝到高級使用,涵蓋了各種常見的開發(fā)場景和技巧,需要的朋友可以參考下
    2024-12-12
  • vue-cli中的圖片資源存放位置詳解

    vue-cli中的圖片資源存放位置詳解

    這篇文章主要介紹了vue-cli中的圖片資源存放位置,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • vue如何解決echarts升級后本地?zé)o法啟動的問題

    vue如何解決echarts升級后本地?zé)o法啟動的問題

    這篇文章主要介紹了vue如何解決echarts升級后本地?zé)o法啟動的問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-06-06
  • vue配置nprogress實現(xiàn)頁面頂部進(jìn)度條

    vue配置nprogress實現(xiàn)頁面頂部進(jìn)度條

    這篇文章主要為大家詳細(xì)介紹了vue配置nprogress實現(xiàn)頁面頂部進(jìn)度條,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-09-09
  • 一文了解Vue 3 的 generate 是這樣生成 render 函數(shù)的

    一文了解Vue 3 的 generate 是這樣生成 render&n

    本文介紹generate階段是如何根據(jù)javascript AST抽象語法樹生成render函數(shù)字符串的,本文中使用的vue版本為3.4.19,感興趣的朋友跟隨小編一起看看吧
    2024-06-06
  • vue中v-model指令與.sync修飾符的區(qū)別詳解

    vue中v-model指令與.sync修飾符的區(qū)別詳解

    本文主要介紹了vue中v-model指令與.sync修飾符的區(qū)別詳解,詳細(xì)的介紹了兩個的用法和區(qū)別,感興趣的可以了解一下
    2021-08-08

最新評論