编写一个俄罗斯方块

编写俄罗斯方块 思路。

1、创建容器数组,方块,

2、下落,左右移动,旋转,判断结束,消除。

 定义一个20行10列的数组表示游戏区。初始这个数组里用0填充,1表示有一个方块,2表示该方块固定了,

然后随机出一个方块,操作左右转,触底变2后,再随机下一个方块,循环直到判定结束。

<template>
    <div>
        <div class="gamebox">
            <div class="table">
                <ul>
                    <li v-for="item in elsStore.gameArray">{{ item }}</li>
                </ul>
            </div>
            <div class="next">
                <ul>
                    <li v-for="item in elsStore.nextArray">{{ item }}</li>
                </ul>
                <p>消除:{{ elsStore.score }}</p>
            </div>
        </div>

        <div class="toolbar">
            <div>
                <el-button type="success" @click="gameStart">开始</el-button>
                <el-button type="success" @click="gameReset">重置</el-button>
            </div>

        </div>

    </div>
</template>

<script setup lang="ts">
import useElsStore from '@/stores/els';
const elsStore = useElsStore();
elsStore.resetTable
//     // I:一次最多消除四层
//     // L(左右):最多消除三层,或消除二层
//     // O:消除一至二层
//     // S(左右):最多二层,容易造成孔洞
//     // Z(左右):最多二层,容易造成孔洞
//     // T:最多二层
let intervalDown: NodeJS.Timer;
const gameStart = () => {
    //  开始游戏  当前游戏中,需要先重置游戏,
    // 放置next,并开始游戏逻辑
    elsStore.randNext;
    intervalDown = setInterval(startDown, 1000);


}
const gameReset = () => {
    clearInterval(intervalDown);
    elsStore.resetTable

}

const startDown = () => {
    console.log("down....");

}

</script>

<style scoped lang="scss">
.gamebox {
    display: flex;
    justify-content: flex-start;

    .next {
        margin-left: 20px;

        p {
            margin-top: 20px;
        }
    }
}

.toolbar {
    display: flex;
    width: 100vw;
    justify-content: center;
    margin-top: 10px;

}
</style> 

//定义关于counter的store
import { defineStore } from 'pinia'
import { enumStoreName } from "../index";
import { ElsTable } from '@/api/room/type';

//defineStore 是返回一个函数 函数命名最好有use前缀,根据函数来进行下一步操作
const useElsStore = defineStore(enumStoreName.elsStore, {
    state: (): ElsTable => {
        return {
            // 主要区域
            gameArray: new Array<Array<number>>(),
            // 下一个图形
            nextArray: new Array<Array<number>>(),
            // 定义俄罗斯方块游戏区域大小
            rows: 20, columns: 10,
            // 对应值 0 空,1有活动方块 , 2有固定方块
            value: 0,
            // 游戏分数
            score: 0
        }
    },
    actions: {
        // 初始化界面
        resetTable() {
            this.gameArray = new Array<Array<number>>();
            this.nextArray = new Array<Array<number>>();
            // reset main
            for (let i = 0; i < this.rows; i++) {
                this.gameArray.push(new Array<number>());
            }
            for (let i = 0; i < this.gameArray.length; i++) {
                for (let j = 0; j < this.columns; j++) {
                    this.gameArray[i].push(this.value);
                }
            }
            // reset next
            for (let i = 0; i < 4; i++) {
                this.nextArray.push(new Array<number>());
            }
            for (let i = 0; i < this.nextArray.length; i++) {
                for (let j = 0; j < 4; j++) {
                    this.nextArray[i].push(this.value);
                }
            }
        },

        randNext(){
            
        }

    },
    getters: {
        getAddress(): string {
            return ""
        },
    },
    persist: {
        key: enumStoreName.elsStore,
        storage: localStorage,
    },
})

export default useElsStore

 

第二阶段:改版后的情况

1、编写ui部分

 <div>
        <div class="gamebox">
            <div class="table">
                <ul>
                    <li v-for="item in elsStore.els.getShowPlate()  ">
                        <span v-for="x in item.split(',')">
                            <div class="box" v-if="x != '0'"
                                :style="'background-color:' + elsStore.els.next_plate.color + ';'"></div>
                        </span>
                    </li>
                </ul>
            </div>
            <div class="next">
                <div class="top">
                    <ul>
                        <li v-for="item in elsStore.els.next_plate.currentString().split('@')">
                            <span v-for="x in item.split(',')">
                                <div class="box" v-if="x != '0'"
                                    :style="'background-color:' + elsStore.els.next_plate.color + ';'"></div>
                            </span>
                        </li>
                    </ul>
                    <p>消除: {{ elsStore.els.score }}</p>
                </div>
                <div class="bottom">
                    <div class="btn">
                        <el-button type="success" @click="gameStart">开始</el-button>
                        <el-button type="success" @click="gameReset">重置</el-button>
                    </div>
                </div>
            </div>
        </div>

        <div class="toolbar">
            <div class="btn">
                <el-button type="success" @click="leftClick" :icon="ArrowLeftBold">左移</el-button>
                <el-button type="success" @click="rightClick" :icon="ArrowRightBold">右移</el-button>
                <el-button type="success" @click="rotateClick" :icon="Refresh">旋转</el-button>
                <el-button type="success" @click="downClick" :icon="Refresh">下落</el-button>
            </div> 
        </div> 
    </div>

 


<style scoped lang="scss">
.gamebox {
    display: flex;
    justify-content: flex-start;

    .table {
        ul {
            width: 60vw;
            border: solid 1px;
            margin: 20px;

            li {
                display: flex;
                width: 60vw;

                span {
                    width: 6vw;
                    height: 6vw;


                    .box {
                        width: 100%;
                        height: 100%;
                        border: 1px solid #000;

                    }
                }
            }
        }
    }




    .next {

        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        margin-top: 40px;

        .top {
            ul {
                width: 24vw;

                li {
                    display: flex;
                    width: 24vw;

                    span {
                        width: 6vw;
                        height: 6vw;
                        border: solid 1px;

                        .box {
                            width: 100%;
                            height: 100%;


                        }


                    }
                }
            }
        }

        p {
            margin-top: 20px;
        }

        .bottom {
            margin-bottom: 148px;

            .btn {
                display: flex;
                flex-direction: column;
                align-items: flex-end;
                justify-content: space-around;

                button {
                    margin-bottom: 5px;
                }
            }
        }
    }
}

.toolbar {
    display: flex;
    width: 100vw;
    justify-content: center;
    margin-top: 10px;
    flex-direction: column;

    .btn {
        display: flex;
        justify-content: center;
    }

}

.el-button {
    height: 70px;
}
</style> 

主要逻辑部分


import { ArrowLeftBold, Refresh, ArrowRightBold } from '@element-plus/icons-vue'
import { GameControl } from "./class/GameControl";
import { reactive  } from "vue";

const elsStore = reactive({
    els: new GameControl()
}) 
 
 


const rotateClick = () => {
    console.log("向右旋转");
    elsStore.els.rotate()
}
const leftClick = () => {
    elsStore.els.current_plate.position.x =
        (elsStore.els.current_plate.position.x > 0) ? elsStore.els.current_plate.position.x - 1 : 0
  
}
const rightClick = () => {
    elsStore.els.current_plate.position.x =
        (elsStore.els.current_plate.position.x + elsStore.els.current_plate.getPlateSize().width < 10)
            ? elsStore.els.current_plate.position.x + 1 : elsStore.els.current_plate.position.x

}
const downClick = () => {

    elsStore.els.current_plate.position.y += 1
}



const timers = () => {
    console.log("游戏循环开始");
    // 检查当前盘是否有重叠的,因为最后一步是让动块下降一格。
    // 因此,如果最后一步没有重叠,那么说明盘已经到底了,游戏结束
    // console.log('currentBox' + elsStore.els.current_plate.name, elsStore.els.current_plate.position.y);

    if (!elsStore.els.checkShowPlateIsOK()) {
        console.log("游戏结束");
        elsStore.els.started = false;
        return false
    }



    // 在Main盘面合法的情况下,需要检查即将触底或碰撞,就触发Lock更新
    if (elsStore.els.willPong()) {

        // console.log("====================Lock================");
        elsStore.els.lock_plate = elsStore.els.getShowPlate().join("@")
        // 消除
        elsStore.els.checkAndClear();
        // 负责下一块给当前动块,并随机一个下一块。
        elsStore.els.newCurrentPlate();
    } else {
        elsStore.els.current_plate.position.y += 1;
    }



    setTimeout(() => {
        if (elsStore.els.started) { timers(); }
    }, 500);

};


const gameStart = () => {

    console.log('游戏开始');
    if (elsStore.els.started) {
        return false;
    }
    elsStore.els.next_plate = elsStore.els.newRndPlate()
    elsStore.els.started = true
    timers();



}

const gameReset = () => {
    console.log('重置游戏');

    elsStore.els = new GameControl()
    elsStore.els.started = false

}

可以看到主要是循环部分。然后就是调gameControl部分

 
import { Config } from "../config";
import { Plate } from "./Plate";


export class GameControl {

    next_plate: Plate;
    current_plate: Plate;
    lock_plate: string;
    started: boolean;
    score: number;

    constructor() {
        this.next_plate = this.newRndPlate()
        this.current_plate = this.copyNextToCurrent();
        this.lock_plate = Config.defuaultLockPlate
        this.started = false
        this.score = 0
        this.init()
    }



    init() {
        // 初始化游戏 
        console.log("初始化游戏");

        // 显示一个等待方块,并等待用户按下开始按钮。 
    }

    // 生成一个随机盘子
    newRndPlate() {
        return new Plate(Plate.PlateType[Math.floor(Math.random() * 6)]);
    }



    // 复制下一个盘子到当前盘子
    private copyNextToCurrent(): Plate {
        let plate = new Plate(this.next_plate.name);
        plate.position.x = 3
        plate.position.y = 0
        return plate
    }




    // 合并盘子 ,用给定的Plate和Lock进行合并,不用检查是否重叠
    private margePlate(plate: Plate) {
        let tmp_plate = plate.currentStringMax().split("@");
        let lockList = this.lock_plate.split("@");
        let newLockList: string[] = []
        // console.log({ tmp_plate, lockList, newLockList });

        // 跟lock合并
        for (let i = 0; i < lockList.length; i++) {
            let lockListi = lockList[i].split(",");
            let tmp_platei = tmp_plate[i].split(",");
            let newLockLine: string[] = []
            for (let j = 0; j < lockListi.length; j++) {
                newLockLine.push("" + eval(lockListi[j] + '+' + tmp_platei[j]))
            }
            newLockList.push(newLockLine.join(","))
        }
        // console.log({ newLockList });
        return newLockList;
    }

    // 检查给定数组是否有重叠
    private checkMainOK(main: string[]): boolean {
        for (let i = 0; i < main.length; i++) {
            const boxList = main[i].split(",")
            for (let j = 0; j < boxList.length; j++) {
                if (eval(boxList[j]) > 1) {
                    return false;
                }
            }
        }
        return true;
    }




    willPong(): boolean {


        let tmp_plate = new Plate(this.current_plate.name);
        tmp_plate.position.x = this.current_plate.position.x
        tmp_plate.position.y = this.current_plate.position.y + 1
        tmp_plate.direction = this.current_plate.direction

        let height = tmp_plate.getPlateSize().height;
        if (tmp_plate.position.y + height > 20) {
            return true
        }

        let newLockList = this.margePlate(tmp_plate);

        return !this.checkMainOK(newLockList);
    }



    getShowPlate(): string[] {

        if (!this.started) {
            return this.lock_plate.split("@")
        }
        // console.log("====================");
        // console.log({ current_plate:this.current_plate,lock_plate:this.lock_plate});
        let newLockList = this.margePlate(this.current_plate);
        // console.log({ newLockList});



        // // 跟lock合并
        // for (let i = 0; i < lockList.length; i++) {
        //     let lockListi = lockList[i].split(",");
        //     let tmp_platei = tmp_plate[i].split(",");
        //     let newLockLine: string[] = []
        //     for (let j = 0; j < lockListi.length; j++) {
        //         newLockLine.push("" + eval(lockListi[j] + '+' + tmp_platei[j]))
        //     }
        //     newLockList.push(newLockLine.join(","))
        // }

        // for (let i = 0; i < lockList.length; i++) {
        //     if (i < tmp_plate.length) {
        //         let lockListi = lockList[i].split(",");
        //         let tmp_platei = tmp_plate[i].split(",");
        //         let newLockLine: string[] = []
        //         for (let j = 0; j < lockListi.length; j++) {
        //             newLockLine.push("" + eval(lockListi[j] + '+' + tmp_platei[j]))
        //         }
        //         newLockList.push(newLockLine.join(","))
        //     } else {
        //         let lockListi = lockList[i].split(",");
        //         let newLockLine: string[] = []
        //         for (let j = 0; j < lockListi.length; j++) {
        //             newLockLine.push(lockListi[j])
        //         }
        //         newLockList.push(newLockLine.join(","))
        //     }
        // }

        return newLockList;

    }


    // 检查getShowPlate是否有大于1的块
    checkShowPlateIsOK() {

        return this.checkMainOK(this.getShowPlate());
    }


    //   newCurrentPlate 函数
    newCurrentPlate() {
        this.current_plate = this.copyNextToCurrent();
        this.next_plate = this.newRndPlate()

    }


    // 旋转后的dir
    rotate() {
        // 如果超界或重叠就不让旋转 仅下部分超界就不让。
        this.current_plate.direction = (this.current_plate.direction + 1) % 4
        if (this.current_plate.position.y + this.current_plate.getPlateSize().height > 20 || (!this.checkShowPlateIsOK())) {
            this.current_plate.direction = (this.current_plate.direction - 1) % 4
        }
    }


    // 消除
    checkAndClear() {
        // 更新lock
        let lockList = this.lock_plate.split("@");
        let tmpList:string[] = []
        lockList.forEach((item ) => {
            if(item!="1,1,1,1,1,1,1,1,1,1"){
                tmpList.push(item)
            }
        });

        for (let index = 0; index < 20-tmpList.length; index++) {
            this.score ++
            tmpList = ['0,0,0,0,0,0,0,0,0,0'].concat(tmpList)
        }


        this.lock_plate = tmpList.join("@");


    }


}


最后就是2个小类

export class Box {
    color: string;
    icon: string;
    disabled: boolean;
    constructor(color: string     ) { this.color = color; this.icon = "Grid"; this.disabled = true; } 
 
}

 
const  defuaultLockPlate: string = "0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0@0,0,0,0,0,0,0,0,0,0"; 


export const  Config =  {
    defuaultLockPlate
 
}

 

import { Box } from "./Box";


interface Pos {
    x: number;
    y: number;
}
export class Plate extends Box {

    // I:一次最多消除四层  (状态横竖2种)
    // L(左):L最多消除三层,或消除二层  (状态横竖4种)
    // R(右):反L最多消除三层,或消除二层   (状态横竖4种)
    // O:消除一至二层  (状态1种)
    // S(左右):最多二层,容易造成孔洞  (状态横竖2种)
    // Z(左右):最多二层,容易造成孔洞 (状态横竖2种)
    // T:最多二层 (状态横竖4种)


    name: string;
    // 字符串数组
    arrString: string[];
    // currentString: string;
    // 位置
    position: Pos;
    // 方向
    direction: number;
    // 是否锁住
    lock: boolean;

    static PlateType = ["I", "L", "O", "S", "Z", "T"]

    constructor(name: string) {


        let colors = ["red", "yellow", "blue", "green", "purple", "orange"];
        switch (name) {
            case "I":
                super(colors[0]);
                this.name = name;
                this.arrString = [
                    "0,0,0,0@1,1,1,1@0,0,0,0@0,0,0,0",
                    "0,1,0,0@0,1,0,0@0,1,0,0@0,1,0,0",
                    "0,0,0,0@1,1,1,1@0,0,0,0@0,0,0,0",
                    "0,1,0,0@0,1,0,0@0,1,0,0@0,1,0,0"]
                break;
            case "L":
                super(colors[1]);
                this.name = name;
                this.arrString = [
                    "0,1,1,1@0,1,0,0@0,0,0,0@0,0,0,0",
                    "0,0,1,0@1,1,1,0@0,0,0,0@0,0,0,0",
                    "0,1,0,0@0,1,0,0@0,1,1,0@0,0,0,0",
                    "0,1,1,0@0,0,1,0@0,0,1,0@0,0,0,0"]
                break;
            case "O":
                super(colors[2]);
                this.name = name;
                this.arrString = [
                    "0,1,1,0@0,1,1,0@0,0,0,0@0,0,0,0",
                    "0,1,1,0@0,1,1,0@0,0,0,0@0,0,0,0",
                    "0,1,1,0@0,1,1,0@0,0,0,0@0,0,0,0",
                    "0,1,1,0@0,1,1,0@0,0,0,0@0,0,0,0",]
                break;
            case "S":
                super(colors[3]);
                this.name = name;
                this.arrString = [
                    "0,0,1,1@0,1,1,0@0,0,0,0@0,0,0,0",
                    "0,1,0,0@0,1,1,0@0,0,1,0@0,0,0,0",
                    "0,0,1,1@0,1,1,0@0,0,0,0@0,0,0,0",
                    "0,1,0,0@0,1,1,0@0,0,1,0@0,0,0,0"]
                break;
            case "Z":
                super(colors[4]);
                this.name = name;
                this.arrString = [
                    "0,1,1,0@0,0,1,1@0,0,0,0@0,0,0,0",
                    "0,0,1,0@0,1,1,0@0,1,0,0@0,0,0,0",
                    "0,1,1,0@0,0,1,1@0,0,0,0@0,0,0,0",
                    "0,0,1,0@0,1,1,0@0,1,0,0@0,0,0,0"]
                break;
            default: //T
                super(colors[5]);
                this.name = name;
                this.arrString = [
                    "0,0,1,0@0,1,1,0@0,0,1,0@0,0,0,0",
                    "0,0,1,0@0,1,1,1@0,0,0,0@0,0,0,0",
                    "0,1,0,0@0,1,1,0@0,1,0,0@0,0,0,0",
                    "0,1,1,1@0,0,1,0@0,0,0,0@0,0,0,0"]
                break;
        }

        this.position = {
            x: -1,
            y: -1
        }
        this.direction = Math.floor(Math.random() * 4)
        this.lock = false

        console.log('创建了一个' + this.name + ' 颜色:' + this.color + ' 方向:' + this.direction);

    }

    // 4*4大小
    public currentString(): string {
        return this.arrString[this.direction]
    }

    //  精简块的内容 最小 化块
    public currentStringMin(): string {
        let plateStr = this.arrString[this.direction]
        let plates: string[] = [];

        // 去掉多余的 行
        plateStr.split("@").forEach((item) => {
            if (eval(item.replace(/,/g, "+")) > 0) {
                plates.push(item);
            }
        });

        // 去掉多余的 列 就是裁剪前面的0和后面的0
        // 计算是块的valueCount 如果少了,就不能裁剪。
        const countPlateValue = (plates: string[]) => {
            let tmpPlateList = plates.map((item) => {
                const sum = item.split(",").reduce(function (prev, cur) {
                    return eval(prev + "+" + cur);
                });
                return sum
            })
            return tmpPlateList.reduce(function (prev, cur) {
                return eval(prev + "+" + cur);
            });
        }

        // console.log("test value", countPlateValue(plates));

        // 裁剪前面的0 
        const cuxsuff = (plates: string[]): string[] => {
            if (plates[0].split(",").length == 1) return plates
            // 尝试裁剪 ,如果长度为1,就不用裁剪了
            let tmpPlateList: string[] = plates.map((item) => {
                let t = item.split(",")
                t.shift()
                return t.join(",")
            })
            if (countPlateValue(tmpPlateList) == countPlateValue(plates)) {
                return cuxsuff(tmpPlateList)
            } else {
                return plates
            }
        }
        // 裁剪后面的0
        const cuxdiff = (plates: string[]): string[] => {
            if (plates[0].split(",").length == 1) return plates
            // 尝试裁剪 ,如果长度为1,就不用裁剪了
            let tmpPlateList: string[] = plates.map((item) => {
                let t = item.split(",")
                t.pop()
                return t.join(",")
            })
            if (countPlateValue(tmpPlateList) == countPlateValue(plates)) {
                return cuxdiff(tmpPlateList)
            } else {
                return plates
            }
        }
        const remainingPlates = cuxdiff(cuxsuff(plates)).join("@");
        return remainingPlates;
    }

    // 格式化成 Mian大小 的块
    public currentStringMax(): string {
        let currentString = this.currentStringMin()  
        let maxY = 20 - this.getPlateSize().height;
        let maxX = 10 - this.getPlateSize().width;
        this.position.x = this.position.x >= maxX ? maxX : this.position.x;
        this.position.y = this.position.y >= maxY ? maxY : this.position.y;
        let x = this.position.x
        let y = this.position.y

        let tmpPlateList = currentString.split("@").map((item) => {
            let prefix: string[] = [];
            let suffix: string[] = [];
            for (let i = 0; i < x; i++) {
                prefix.push("0")
            }
            for (let i = 0; i < 10 - item.split(",").length - x; i++) {
                suffix.push("0")
            }
            return prefix.concat(item.split(",").concat(suffix)).join(",");
        });
        for (let index = 0; index < y; index++) {
            tmpPlateList = ['0,0,0,0,0,0,0,0,0,0'].concat(tmpPlateList)
        }

        for (let index = 0; index < 20 - y - currentString.split("@").length; index++) {
            tmpPlateList = tmpPlateList.concat(['0,0,0,0,0,0,0,0,0,0'])
        }
        return tmpPlateList.join("@")
    }

    // 获取长和高
    public getPlateSize(): { width: number; height: number; } {
        return {
            width: this.currentStringMin().split("@")[0].split(",").length,
            height: this.currentStringMin().split("@").length
        }
    }


}

最后是完整的源码下  http s://gitcode.net/ldy889/game-els  项目删掉了一些没用的东西,只保留了核心代码,需要自己去除一些错误。比如修改路径,无效的引入。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/84270.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Nvidia Jetson 编解码开发(3)解决H265解码报错“PPS id out of range”

1.问题描述 基于之前的开发程序 Nvidia Jetson 编解码开发(2)Jetpack 4.x版本Multimedia API 硬件编码开发--集成encode模块_free-xx的博客-CSDN博客 通过Jetson Xavier NX 硬编码的H265发出后, 上位机断点播放发出来的H265码流, 会报“PPS id out of range” 错误 …

2023年最佳JavaScript框架:React、Vue、Angular和Node.js的比较

文章目录 React&#xff1a;构建用户界面的首选Vue&#xff1a;简单优雅的前端框架Angular&#xff1a;Google支持的全面框架Node.js&#xff1a;服务器端的JavaScript运行环境比较不同框架的优势与劣势React&#xff1a;Vue&#xff1a;Angular&#xff1a;Node.js&#xff1a…

Pytest使用fixture实现token共享

同学们在做pytest接口自动化时&#xff0c;会遇到一个场景就是不同的测试用例需要有一个登录的前置步骤&#xff0c;登录完成后会获取到token&#xff0c;用于之后的代码中。首先我先演示一个常规的做法。 首先在conftest定义一个login的方法&#xff0c;方法返回token pytes…

python 打印一个条形堆积图

背景 今天介绍一个不使用 matplot&#xff0c;通过 DebugInfo模块打印条形堆积图 的方法。 引入模块 pip install DebugInfo打印销售转化数据 下面的代码构建了两个销售团队&#xff0c;团队A 和团队B&#xff1b;两个团队的销售数据构成了公司总的销售成果。以条形堆积图的…

bug记录:微信小程序 给button使用all: initial重置样式

场景&#xff1a;通过uniapp开发微信小程序 &#xff0c;使用uview的u-popup弹窗&#xff0c;里面内嵌了一个原生button标签&#xff0c;因为微信小程序的button是有默认样式的&#xff0c;所以通过all: initial重置样式 。但是整个弹窗的点击事件都会被button上面的点击事件覆…

node没有自动安装npm时,如何手动安装 npm

之前写过一篇使用 nvm 管理 node 版本的文章&#xff0c;node版本管理&#xff08;Windows&#xff09; 有时候&#xff0c;我们使用 nvm 下载 node 时&#xff0c;node 没有自动下载 npm &#xff0c;此时就需要我们自己手动下载 npm 1、下载 npm下载地址&#xff1a;&…

java请求SAP系统,发起soap的xml报文,实体类转换,idea自动生成教程

1、将接口的网页地址&#xff0c;右键保存&#xff0c;然后修改文件后缀为wsdl文件 2、idea全局搜索 wsdl&#xff0c;找到自动转换javabean插件&#xff1a; 3、点击后&#xff0c;选择下载改完后缀的文件(选择)&#xff1a; 4、将无用的class文件删除掉 5、请求sap的地址为…

嵌入式蓝海变红海?其实是大浪淘沙!

嵌入式是当下热门的职业方向之一&#xff0c;吸引了众多求职者的目光。然而&#xff0c;有人担心大家一拥而上&#xff0c;导致嵌入式就业竞争激烈&#xff0c;找工作难度大。其实&#xff0c;嵌入式行业的竞争并非无法逾越的天堑&#xff0c;也远远没有从蓝海变成红海&#xf…

【Redis从头学-7】Redis中的Set数据类型实战场景之用户画像去重、共同关注、专属粉丝

&#x1f9d1;‍&#x1f4bb;作者名称&#xff1a;DaenCode &#x1f3a4;作者简介&#xff1a;啥技术都喜欢捣鼓捣鼓&#xff0c;喜欢分享技术、经验、生活。 &#x1f60e;人生感悟&#xff1a;尝尽人生百味&#xff0c;方知世间冷暖。 &#x1f4d6;所属专栏&#xff1a;Re…

春秋云镜 CVE-2019-2725

春秋云镜 CVE-2019-2725 Weblogic < 10.3.6 ‘wls-wsat’ XMLDecoder 反序列化漏洞 靶标介绍 Oracle Fusion Middleware&#xff08;子组件&#xff1a;Web Services&#xff09;的 Oracle WebLogic Server 组件中的漏洞。受影响的受支持版本为 10.3.6.0.0 和 12.1.3.0.0。…

Python爬虫实战案例——第一例

X卢小说登录(包括验证码处理) 地址&#xff1a;aHR0cHM6Ly91LmZhbG9vLmNvbS9yZWdpc3QvbG9naW4uYXNweA 打开页面直接进行分析 任意输入用户名密码及验证码之后可以看到抓到的包中传输的数据明显需要的是txtPwd进行加密分析。按ctrlshiftf进行搜索。 定位来到源代码中断点进行调…

python 开发环境(PyCharm)搭建指南

Python 的下载并安装 参考&#xff1a;Python基础教程——搭建Python编程环境 下载 Python Python 下载地址&#xff1a;官网 &#xff08;1&#xff09;点击【Downloads】>>>点击【Windows】>>>点击【Python 3.x.x】下载最新版 Python&#xff1b; Pyt…

resource doesn‘t have a corresponding Go package.

resource doesnt have a corresponding Go package. GO这个鬼东西不能直接放src下。 ************ Building Go project: ProjectGoTest ************with GOPATH: D:\Go;D:\eclipse-jee-oxygen-2-win32-x86_64\workspace\ProjectGoTest >> Running: D:\Go\bin\go.exe …

SNAT和DNAT

SNAT和DNAT 一、SNAT策略及应用1.1SNAT策略概述1.2开启SNAT的命令1.2.1 临时打开1.2.2永久打开 1.3SNAT转换1&#xff1a;固定的公网IP地址1.4SNAT转换2&#xff1a;非固定的公网IP地址&#xff08;共享动态IP地址&#xff09;1.5SNAT案例1.5.1实验准备1.5.2配置网关服务器&…

(数字图像处理MATLAB+Python)第十章图像分割-第三,四节:区域分割和基于聚类的图像分割

文章目录 一&#xff1a;区域分割&#xff08;1&#xff09;区域生长A&#xff1a;原理B&#xff1a;示例C&#xff1a;程序 &#xff08;2&#xff09;区域合并A&#xff1a;原理B&#xff1a;示例C&#xff1a;程序 &#xff08;3&#xff09;区域分裂A&#xff1a;原理B&…

二叉树的遍历

二叉树的遍历 关于二叉树的遍历方式&#xff0c;要知道二叉树遍历的基本方式都有哪些。二叉树主要有两种遍历方式&#xff1a; 深度优先遍历&#xff1a;先往深走&#xff0c;遇到叶子节点再往回走。 前序遍历&#xff08;递归法&#xff0c;迭代法&#xff09;中序遍历&#…

tailscale使用教程(远程连接服务器)

tailscale&#xff1a;将多个设备放在同一局域网下&#xff0c;实现异地组网。 首先进入tailscale官网&#xff0c;根据系统需求进行下载 需要远程的设备和被远程的设备都需要下载。 然后两个设备均登录同一账号即可 注&#xff1a;这里重点讲一下linux操作系统上的操作&…

【3Ds Max】布料命令的简单使用

简介 在3ds Max中&#xff0c;"布料"&#xff08;Cloth&#xff09;是一种模拟技术&#xff0c;用于模拟物体的布料、织物或软体的行为&#xff0c;例如衣物、帆布等。通过应用布料模拟&#xff0c;您可以模拟出物体在重力、碰撞和其他外力作用下的变形和动态效果。…

Zookeeper集群单节点启动成功但未同步其他节点数据

首先排查节点启动是否正常&#xff1a; 在zookeeper的bin目录下执行&#xff1a;sh zkServer.sh status 判断当前节点数据leader 还是follower 节点都启动正常&#xff0c;但某一个zookeeper集群节点&#xff08;下面简称“异常节点”&#xff09;不同步其他节点数据&#xf…

7. CSS(四)

目录 一、浮动 &#xff08;一&#xff09;传统网页布局的三种方式 &#xff08;二&#xff09;标准流&#xff08;普通流/文档流&#xff09; &#xff08;三&#xff09;为什么需要浮动&#xff1f; &#xff08;四&#xff09;什么是浮动 &#xff08;五&#xff09;浮…