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

vue3實(shí)現(xiàn)旋轉(zhuǎn)圖片驗(yàn)證

 更新時(shí)間:2022年04月23日 09:54:31   作者:放風(fēng)嘍  
這篇文章主要為大家詳細(xì)介紹了vue3實(shí)現(xiàn)旋轉(zhuǎn)圖片驗(yàn)證,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue3實(shí)現(xiàn)旋轉(zhuǎn)圖片驗(yàn)證的具體代碼,供大家參考,具體內(nèi)容如下

一、前言

一個(gè)突發(fā)奇想的創(chuàng)作。

二、代碼

<template>
? <el-dialog
? ? ? v-model="dialogVisible"
? ? ? width="15%"
? ? ? :before-close="handleClose">
? ? <el-image :src="imageUrl" :style="xuanzhuan" class="w-full flex justify-center rounded-full overflow-hidden">
? ? ? <template #error>
? ? ? ? <div class="image-slot">
? ? ? ? ? <i class="el-icon-picture-outline text-3xl"></i>
? ? ? ? </div>
? ? ? </template>
? ? </el-image>
? ? <template #footer>
? ? ? <div class="w-full mx-1 my-1 h-8 bg-gray-300 relative">
? ? ? ? <i @mousedown="rangeMove" :style="leftnum" class="el-icon-d-arrow-right h-8 w-8 bg-white border absolute top-0 bottom-0 flex justify-center items-center cursor-pointer select-none"></i>
? ? ? </div>
? ? ? <div class="w-full flex justify-evenly">
? ? ? ? <el-button @click="chongzhi()">重置</el-button>
? ? ? ? <el-button type="primary" @click="tijiao()">確定</el-button>
? ? ? </div>
? ? </template>
? </el-dialog>

</template>

<script lang="ts">
import {computed, defineComponent, ref} from "vue";
export default defineComponent({
? name:"xuanzhuan",
? setup(prop,content) {
? ? // 左側(cè)距離和移動(dòng)距離
? ? const disX = ref(0)
? ? const leftnum = computed(()=>{
? ? ? return `left: ${disX.value}px`
? ? })
? ? // 角度和 旋轉(zhuǎn)角度
? ? const jiaodu = ref(0)
? ? const xuanzhuan = computed(()=>{
? ? ? return `transform:rotate(${jiaodu.value}deg);`
? ? })

? ? const dialogVisible = ref(false)
? ? const imageUrl = ref("http://1812.img.pp.sohu.com.cn/images/blog/2009/11/18/18/8/125b6560a6ag214.jpg")
? ? function getimage(){
? ? ? console.log("向后臺(tái)獲取圖片")
? ? }
? ? function init(){
? ? ? dialogVisible.value = true
? ? ? getimage()
? ? }
? ? function handleClose(){
? ? ? jiaodu.value = 0
? ? ? disX.value = 0
? ? ? imageUrl.value = ""
? ? ? dialogVisible.value = false
? ? }
? ? function rangeMove(e:any){
? ? ? let ele = e.target;
? ? ? let startX = e.clientX - disX.value;
? ? ? let eleWidth = ele.offsetWidth;
? ? ? let parentWidth = ?ele.parentElement.offsetWidth;
? ? ? let MaxX = parentWidth - eleWidth;
? ? ? document.onmousemove = (e)=>{
? ? ? ? let endX = e.clientX;
? ? ? ? disX.value = endX - startX;
? ? ? ? if(disX.value<=0){
? ? ? ? ? disX.value = 0;
? ? ? ? }else if(disX.value>=MaxX){ ? //減去滑塊的寬度,體驗(yàn)效果更好
? ? ? ? ? disX.value = MaxX;
? ? ? ? }

? ? ? ? // 計(jì)算滑動(dòng)距離與全長(zhǎng)的比例
? ? ? ? const bili = disX.value / (MaxX-eleWidth)
? ? ? ? // 用比例乘以360度,就是旋轉(zhuǎn)角度
? ? ? ? jiaodu.value = bili * 360
? ? ? }
? ? ? document.onmouseup=()=>{
? ? ? ? document.onmousemove = null;
? ? ? ? document.onmouseup = null;
? ? ? }
? ? }
? ? // 逐步減少,看上去好看點(diǎn)
? ? function jianshao(disbuchang:number,jiaobubuchang:number){
? ? ? jiaodu.value = jiaodu.value - jiaobubuchang
? ? ? disX.value = disX.value - disbuchang
? ? ? if(disX.value <=0 ){
? ? ? ? jiaodu.value = 0
? ? ? ? disX.value = 0
? ? ? }
? ? }
? ? // 點(diǎn)擊重置,使用異步方法,逐步回到原點(diǎn)
? ? function chongzhi(){
? ? ? const disbuchang = 50
? ? ? const jiaobubuchang = disbuchang/disX.value * jiaodu.value
? ? ? const mandian = setInterval(()=>{
? ? ? ? if(disX.value == 0){
? ? ? ? ? clearInterval(mandian)
? ? ? ? }else{
? ? ? ? ? jianshao(disbuchang,jiaobubuchang)
? ? ? ? }
? ? ? },10)
? ? }
? ? // 點(diǎn)擊確定
? ? function tijiao(){
? ? ? if(disX.value == 0){
? ? ? ? return
? ? ? }
? ? ? console.log("后端驗(yàn)證成功")
? ? ? // 成功后,觸發(fā)父組件方法。
? ? ? content.emit("get")
? ? }
? ? return {
? ? ? handleClose,
? ? ? imageUrl,
? ? ? dialogVisible,
? ? ? init,
? ? ? rangeMove,
? ? ? leftnum,
? ? ? xuanzhuan,
? ? ? chongzhi,
? ? ? tijiao,
? ? }
? },
? components:{},
})
</script>

<style scoped>

</style>

css用的是tailwindcss。

三.使用方法

<xuanzhuan ref="myxuanzhuan" @get="chenggong"></xuanzhuan>

setup(prop,content) {
? ? const myxuanzhuan:any = ref(null)
? ? function ceshi(){
? ? ? myxuanzhuan.value.init()
? ? }
? ? function chenggong(){
?? ??? ?console.log("成功的回調(diào)")
?? ?}
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 自帶氣泡提示的vue校驗(yàn)插件(vue-verify-pop)

    自帶氣泡提示的vue校驗(yàn)插件(vue-verify-pop)

    這篇文章主要為大家詳細(xì)介紹了自帶氣泡提示的vue校驗(yàn)插件,vue-verify-pop的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • 在Vue.js中使用Mixins的方法

    在Vue.js中使用Mixins的方法

    本篇文章主要介紹了在Vue.js中使用Mixins的方法,Vue的Mixins是非常實(shí)用的編程方式,可以使代碼變得容易理解,有興趣的一起來(lái)了解一下
    2017-09-09
  • VUE之關(guān)于store狀態(tài)管理核心解析

    VUE之關(guān)于store狀態(tài)管理核心解析

    這篇文章主要介紹了VUE之關(guān)于store狀態(tài)管理核心解析,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • 詳解vue 組件

    詳解vue 組件

    這篇文章主要介紹了詳解vue 組件的相關(guān)知識(shí),文中講解非常細(xì)致,代碼供大家參考學(xué)習(xí),感興趣的朋友可以了解下
    2020-06-06
  • Vue3.0實(shí)現(xiàn)圖片預(yù)覽組件(媒體查看器)功能

    Vue3.0實(shí)現(xiàn)圖片預(yù)覽組件(媒體查看器)功能

    最近項(xiàng)目中有個(gè)場(chǎng)景,一組圖片、視頻、音頻、文件數(shù)據(jù),要求點(diǎn)擊圖片可以放大預(yù)覽,左右可以切換音視頻、文件,支持鼠標(biāo)及各種鍵控制?縮放,左右旋轉(zhuǎn),移動(dòng)等功能,這篇文章主要介紹了Vue3.0實(shí)現(xiàn)圖片預(yù)覽組件(媒體查看器),需要的朋友可以參考下
    2023-12-12
  • vue點(diǎn)擊導(dǎo)航頁(yè)面實(shí)現(xiàn)自動(dòng)滾動(dòng)到特定位置

    vue點(diǎn)擊導(dǎo)航頁(yè)面實(shí)現(xiàn)自動(dòng)滾動(dòng)到特定位置

    這篇文章主要介紹了vue點(diǎn)擊導(dǎo)航頁(yè)面實(shí)現(xiàn)自動(dòng)滾動(dòng)到特定位置方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • Vue組件之間的數(shù)據(jù)共享詳解

    Vue組件之間的數(shù)據(jù)共享詳解

    這篇文章主要為大家介紹了Vue組件之間的數(shù)據(jù)共享,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2021-11-11
  • 淺析vue中$nextTick的作用與原理

    淺析vue中$nextTick的作用與原理

    這篇文章主要為大家詳細(xì)介紹一下Vue中$nextTick的作用于原理,這也是面試中常常考到的問(wèn)題,文中的示例代碼講解詳細(xì),對(duì)我們深入了解Vue有一定的幫助,需要的小伙伴可以參考一下
    2023-10-10
  • vue-resource 攔截器(interceptor)的使用詳解

    vue-resource 攔截器(interceptor)的使用詳解

    本篇文章主要介紹了vue-resource 攔截器(interceptor)的使用詳解,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-07-07
  • vue2.0項(xiàng)目集成Cesium的實(shí)現(xiàn)方法

    vue2.0項(xiàng)目集成Cesium的實(shí)現(xiàn)方法

    這篇文章主要介紹了vue2.0項(xiàng)目集成Cesium的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07

最新評(píng)論