最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue3實現(xiàn)抽獎模板設(shè)置

 更新時間:2022年03月09日 10:27:19   作者:吃瓜群眾歡樂多  
這篇文章主要為大家詳細(xì)介紹了vue3實現(xiàn)抽獎模板設(shè)置,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了vue3實現(xiàn)抽獎模板設(shè)置的具體方法,供大家參考,具體內(nèi)容如下

效果圖

代碼

<template>
? <div>
? ? <h4>抽獎模板設(shè)置</h4>

? ? <div class="container">
? ? ? <ul class="ul-box">
? ? ? ? <li
? ? ? ? ? v-for="(item,index) in list"
? ? ? ? ? :key="item.id"
? ? ? ? ? @click.stop="handleClickItem(item,index)"
? ? ? ? >
? ? ? ? ? {{item.id}}-{{item.title}}
? ? ? ? </li>
? ? ? </ul>

? ? ? <div
? ? ? ? class="pop-box"
? ? ? ? v-show="visible"
? ? ? >
? ? ? ? <div
? ? ? ? ? class="popup"
? ? ? ? ? :style="{left:clickIndexList[0]+'px',top:clickIndexList[1]+'px'}"
? ? ? ? >
? ? ? ? ? <span><em></em></span>
? ? ? ? ? <div>
? ? ? ? ? ? <p
? ? ? ? ? ? ? class="p-title"
? ? ? ? ? ? ? v-for="(item) in selectList"
? ? ? ? ? ? ? :key="item.id"
? ? ? ? ? ? ? @click.stop="handleChoose(item)"
? ? ? ? ? ? >{{item.title}}</p>
? ? ? ? ? </div>
? ? ? ? </div>
? ? ? </div>
? ? </div>

? </div>

</template>
<script lang="ts">
import { defineComponent, reactive, toRefs, onMounted } from 'vue';
const WIDTH = 100;
export default defineComponent({
? name: 'test',
? components: {},
? setup() {
? ? const state = reactive({
? ? ? list: [
? ? ? ? { id: 1 },
? ? ? ? { id: 2 },
? ? ? ? { id: 3 },
? ? ? ? { id: 4 },
? ? ? ? { id: 5, title: '抽獎' },
? ? ? ? { id: 6 },
? ? ? ? { id: 7 },
? ? ? ? { id: 8 },
? ? ? ? { id: 9 },
? ? ? ],
? ? ? selectList: [
? ? ? ? { id: 1, title: '謝謝參與' },
? ? ? ? { id: 2, title: 'iphone13' },
? ? ? ? { id: 3, title: '領(lǐng)克06' },
? ? ? ? { id: 4, title: '華為p40' },
? ? ? ],
? ? ? visible: false,
? ? ? clickIndexList: [],
? ? ? clickIndex: 0,
? ? });

? ? const xyList = [
? ? ? [0, 0],
? ? ? [WIDTH, 0],
? ? ? [WIDTH * 2, 0],
? ? ? [0, WIDTH],
? ? ? [WIDTH, WIDTH],
? ? ? [WIDTH * 2, WIDTH],
? ? ? [0, WIDTH * 2],
? ? ? [WIDTH, WIDTH * 2],
? ? ? [WIDTH * 2, WIDTH * 2],
? ? ];

? ? const hide = () => {
? ? ? state.visible = false;
? ? };

? ? onMounted(() => {
? ? ? document.addEventListener('click', hide);
? ? });

? ? const handleClickItem = (item, index) => {
? ? ? if (index === 4) {
? ? ? ? return;
? ? ? }
? ? ? state.clickIndexList = xyList[index];
? ? ? state.clickIndex = index;
? ? ? state.visible = true;
? ? };

? ? const handleChoose = (item) => {
? ? ? state.list[state.clickIndex].title = item.title;
? ? ? hide();
? ? };

? ? return {
? ? ? handleClickItem,
? ? ? hide,
? ? ? handleChoose,
? ? ? ...toRefs(state),
? ? };
? },
});
</script>
<style lang="less" scoped>
.container {
? position: relative;

? .ul-box {
? ? display: flex;
? ? flex-wrap: wrap;
? ? width: 300px;
? ? li {
? ? ? width: 100px;
? ? ? height: 100px;
? ? ? background: pink;
? ? ? border: 1px solid #fff;
? ? ? display: flex;
? ? ? justify-content: center;
? ? ? align-items: center;
? ? ? cursor: pointer;
? ? }
? }
? .p-title {
? ? margin: 0;
? ? min-width: 150px;
? ? font-size: 14px;
? ? line-height: 1.4;
? ? padding: 10px 20px;
? ? cursor: pointer;
? }
? .p-title:hover {
? ? background: #e6ebf5;
? }

? .pop-box .popup {
? ? width: 200px;
? ? background: #fff;
? ? color: #333;
? ? border-radius: 4px;
? ? position: absolute;
? ? top: 30px;
? ? left: 30px;
? ? border: 1px solid #e6ebf5;
? ? margin-left: -50px;
? ? margin-top: 60px;
? ? z-index: 9999;
? ? animation: left 1s;
? }
? .pop-box .popup span {
? ? display: block;
? ? width: 0;
? ? height: 0;
? ? border-width: 0 10px 10px;
? ? border-style: solid;
? ? border-color: transparent transparent #e6ebf5;
? ? position: absolute;
? ? top: -10px;
? ? left: 50%; /* 三角形居中顯示 */
? ? margin-left: -10px; /* 三角形居中顯示 */
? }
? .pop-box .popup em {
? ? display: block;
? ? width: 0;
? ? height: 0;
? ? border-width: 0 10px 10px;
? ? border-style: solid;
? ? border-color: transparent transparent #fff;
? ? position: absolute;
? ? top: 1px;
? ? left: -10px;
? }
}
</style>

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

相關(guān)文章

最新評論

溧阳市| 余庆县| 丹寨县| 舟山市| 乌苏市| 维西| 抚顺县| 武义县| 浦北县| 准格尔旗| 侯马市| 太原市| 石河子市| 兴仁县| 文昌市| 明溪县| 肥西县| 东宁县| 岐山县| 宜兰市| 南雄市| 洞头县| 晋州市| 昌都县| 大新县| 安平县| 新化县| 沙田区| 仙桃市| 凤城市| 江陵县| 循化| 祁阳县| 河北省| 寿光市| 图木舒克市| 昌都县| 秦皇岛市| 利川市| 蕉岭县| 定襄县|