<template> <div v-if="prize.id>0"> <div></div> <div> <h3>恭喜您</h3> <p> <img :src="prize.img" alt> </p> <h4>获得 <span></span> <span>{{prize.name}}</span> </h4> <div> <a href="javascript:;" @click="closeLotteryEmit">知道了</a> </div> </div> </div> </template> <script> export default { props: { prize: { type: Object, default: () => { return { id: 0 } } } }, methods: { closeLotteryEmit () { this.$emit('closeLotteryPop') } } } </script>
抽奖组件运用在需要使用的页面中,此页面需要为抽奖组件提前准备好预置奖品列表和中奖结果信息,并提供好抽奖方法供子组件(抽奖组件)触发,触发完更改抽奖结果响应式传入到抽奖组件中。
<template> <section> <div>您有一次抽奖机会,祝君好运~~~</div> <BigTurntable :prizes="prizeList" :lotteryResult="lotteryResult" @lottery="lottery" /> </section> </template> <script> import { mapGetters, mapActions } from 'vuex' import BigTurntable from '@/components/bigTurntable.vue' export default { name: 'BigTurntableRun', created () { var self = this self.getPrizeList() }, components: { BigTurntable }, computed: { ...mapGetters({ prizeList: 'lottery/prizeList', lotteryResult: 'lottery/lotteryResult' }) }, methods: { ...mapActions({ getPrizeList: 'lottery/getPrizeList', lottery: 'lottery/lottery' }) } } </script>
总结
以上所述是小编给大家介绍的Vue.js实现大转盘抽奖总结及实现思路,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
您可能感兴趣的文章: