久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      vuejs 可以做轉(zhuǎn)盤嗎

      vuejs可以做轉(zhuǎn)盤,其實現(xiàn)方法:1、創(chuàng)建抽獎按鈕;2、獲取轉(zhuǎn)盤應(yīng)該停止的位置;3、與后臺交互;4、在動畫結(jié)束后停在步驟2設(shè)置的地方;5、設(shè)置提示中獎解鎖功能。

      vuejs 可以做轉(zhuǎn)盤嗎

      本文操作環(huán)境:windows7系統(tǒng)、Vue2.9.6版、Dell G3電腦。

      vuejs 可以做轉(zhuǎn)盤嗎?

      Vue中可配置的圓形抽獎轉(zhuǎn)盤組件

      一、整個抽獎流程的思路分析:

      1. 點擊了轉(zhuǎn)盤正中間的指針(即開始抽獎按鈕),判斷是否可以轉(zhuǎn)動(具體邏輯封裝在canBeRotated()里–①當(dāng)前擁有的抽獎次數(shù)是否大于0②現(xiàn)在是否正在轉(zhuǎn)動著(被鎖著)),判斷通過則進(jìn)行下一步, 否則彈出相應(yīng)提示。
      2. 獲取轉(zhuǎn)盤應(yīng)該停止的位置,應(yīng)該與后臺交互,但這里僅作演示用途, 本地隨機(jī)抽取0~5。
      3. 與后臺交互成功獲取到該停止的位置后,鎖定轉(zhuǎn)盤且減少抽獎次數(shù)。
      4. 告訴轉(zhuǎn)盤組件,開始轉(zhuǎn)動了,并且動畫結(jié)束后停在步驟2設(shè)置的地方。
      5. 轉(zhuǎn)盤轉(zhuǎn)動,停在步驟3設(shè)置的地方后再提示中獎,解鎖。

      二、圓形抽獎轉(zhuǎn)盤組件需要做的事情

      1. 可以自定義每一格轉(zhuǎn)盤的背景顏色,外邊框的顏色。(turntableStyleOption屬性)
      2. 轉(zhuǎn)盤的大小與位置。(在調(diào)用時,給組件加個class,代碼里為turntable
      3. 自定義這個轉(zhuǎn)盤運(yùn)轉(zhuǎn)起來要轉(zhuǎn)過的圈數(shù)。(rotateCircle屬性)
      4. 可以自定義運(yùn)轉(zhuǎn)動畫的時長。(duringTime屬性)
      5. 通過接收到父組件傳遞過來的獎品信息(prizeData),顯示在每一格轉(zhuǎn)盤的位置。(計算要根據(jù)圓心旋轉(zhuǎn)的角度getRotateAngle()方法)
      6. 被父組件調(diào)用后就開始轉(zhuǎn)動,并在指定位置停下的方法(rotate),結(jié)束動畫后告訴父組件已停下。
      7. 獎品的名稱和圖片可以自定義樣式。

      三、頁面預(yù)覽

      vuejs 可以做轉(zhuǎn)盤嗎

      四、基礎(chǔ)用法

      1. 引用
      import roundTurntable from './components/roundTurntable';
      1. 聲明
      components: {   roundTurntable },
      1. 調(diào)用
      <round-turntable   ref="roundTurntable"   :prizeData="prizeData"   :rotateCircle="rotateCircle"   :duringTime="duringTime"   :turntableStyleOption="turntableStyleOption"   @endRotation="endRotation"   class="turntable">     <template slot="item" slot-scope="scope">       <p class="turntable-name">{{ scope.item.prizeName }}</p>       <p class="turntable-img">         <img :src="scope.item.prizeImg">       </p>     </template> </round-turntable>
      data() {   return {     // 轉(zhuǎn)盤上的獎品數(shù)據(jù)     prizeData: [    {      id: 1,      prizeName: '2000元京東券',      prizeImg: 'http://demo.sc.chinaz.net/Files/DownLoad/webjs1/201803/jiaoben5789/images/1.png',    },    {      id: 2,      prizeName: '300元京東券',      prizeImg: 'http://demo.sc.chinaz.net/Files/DownLoad/webjs1/201803/jiaoben5789/images/7.png',    },    {      id: 3,      prizeName: '50個比特幣',      prizeImg: 'http://demo.sc.chinaz.net/Files/DownLoad/webjs1/201803/jiaoben5789/images/3.png',    },    {      id: 4,      prizeName: '50元話費券',      prizeImg: 'http://demo.sc.chinaz.net/Files/DownLoad/webjs1/201803/jiaoben5789/images/4.png',    },    {      id: 5,      prizeName: '100元話費券',      prizeImg: 'http://demo.sc.chinaz.net/Files/DownLoad/webjs1/201803/jiaoben5789/images/5.png',    },    {      id: 6,      prizeName: '100個比特幣',      prizeImg: 'http://demo.sc.chinaz.net/Files/DownLoad/webjs1/201803/jiaoben5789/images/6.png',    }   ],   // 轉(zhuǎn)動的圈數(shù)   rotateCircle: 6,   // 轉(zhuǎn)動需要持續(xù)的時間(s)   duringTime: 4.5,   // 轉(zhuǎn)盤樣式的選項   turntableStyleOption: {     // 背景色     prizeBgColors: ['#AE3EFF', '#4D3FFF', '#FC262C', '#3A8BFF', '#EE7602', '#FE339F'],     // 轉(zhuǎn)盤的外邊框顏色     borderColor: '#199301',   },  } }, methods: {   // 已經(jīng)轉(zhuǎn)動完轉(zhuǎn)盤觸發(fā)的函數(shù)    endRotation() {       // 提示中獎       alert(`恭喜您獲獎啦,您的獎品是:${this.prizeData[this.prizeIndex].prizeName}`);    }, },
      .turntable {   position: absolute;   left: calc(50% - 200px);   top: calc(50% - 200px);   width: 400px;   height: 400px; } .turntable-name {   /*background: pink;*/   position: absolute;   left: 10px;   top: 20px;   width: calc(100% - 20px);   font-size: 26px;   text-align: center;   color: #fff; }   .turntable-img {   position: absolute;   /*要居中就要50% - 寬度 / 2*/   left: calc(50% - 80px / 2);   top: 60px;   width: 80px;   height: 80px;   img {     display: inline-block;     width: 100%;     height: 100%;   } }

      五、roundTurntable組件的屬性說明

      參數(shù) 說明 類型 默認(rèn)值
      ref 獲取這組件的dom節(jié)點,調(diào)用子組件的開始轉(zhuǎn)動動畫方法要用到this.$refs[refName].rotate(index) string
      prizeData 顯示在轉(zhuǎn)盤上的獎品數(shù)據(jù) array
      rotateCircle 轉(zhuǎn)盤要轉(zhuǎn)過的圈數(shù) number 6
      duringTime 轉(zhuǎn)動需要持續(xù)的時間(單位為秒s number 4.5
      turntableStyleOption 轉(zhuǎn)盤的樣式選項(背景色、外邊框顏色) object { prizeBgColors: ['#AE3EFF', '#4D3FFF', '#FC262C', '#3A8BFF', '#EE7602', '#FE339F'], borderColor: '#199301' }
      class 用來定義轉(zhuǎn)盤位置和大小的樣式 string

      六、roundTurntable組件的事件說明

      事件名稱 說明 回調(diào)參數(shù)
      endRotation 轉(zhuǎn)盤停下來后觸發(fā)的事件回調(diào)

      七、完整項目代碼

      https://github.com/LiaPig/vue-round-turntable

      使用到的獎品圖片和指針圖片均來自:

      http://sc.chinaz.com/jiaobendemo.aspx?downloadid=12018113053246

      贊(0)
      分享到: 更多 (0)
      ?
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號