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

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

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

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

效果圖

代碼

<template>
? <div>
? ? <h4>抽獎(jiǎng)模板設(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: '抽獎(jiǎng)' },
? ? ? ? { 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>

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

相關(guān)文章

最新評(píng)論

拉孜县| 无棣县| 灵川县| 杭锦后旗| 资兴市| 沙田区| 化州市| 潞西市| 如东县| 汾阳市| 佳木斯市| 九江市| 凤台县| 保亭| 黑山县| 凤庆县| 武宁县| 得荣县| 象山县| 深水埗区| 永川市| 崇义县| 泾阳县| 桐庐县| 吉隆县| 石家庄市| 东乡族自治县| 图木舒克市| 深泽县| 涟源市| 西丰县| 永吉县| 达州市| 吕梁市| 重庆市| 乾安县| 云南省| 寿光市| 合江县| 孝昌县| 泸州市|