编写一个俄罗斯方块

news2024/12/25 9:24:47

编写俄罗斯方块 思路。

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  项目删掉了一些没用的东西,只保留了核心代码,需要自己去除一些错误。比如修改路径,无效的引入。

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

k8s容器加入host解析字段

一、通过edit或path来修改 kubectl edit deploy /xxxxx. x-n cattle-system xxxxx为你的资源对象名称 二、添加字段 三、code hostAliases:- hostnames:- www.rancher.localip: 10.10.2.180

【多目标跟踪】 FairMOT 耗时三天!!!单句翻译

多目标跟踪 FairMOT Abstract Multi-object tracking (MOT) is an important prob-lem in computer vision which has a wide range of applica-tions. Formulating MOT as multi-task learning of object de-tection and re-ID in a single network is appealing since ital…

Java minecraft(我的世界)环境部署

Java minecraft&#xff08;我的世界&#xff09;环境部署 博主博客 https://blog.uso6.comhttps://blog.csdn.net/dxk539687357 本文主要讲解我的世界的环境搭建&#xff0c; 包括搭建服务端和客户端&#xff0c; 为了避免不必要的麻烦最好是遵守 MINECRAFT 使用准则&#x…

AcrelEMS-SW智慧水务能效管理平台解决方案-安科瑞黄安南

系统概述 安科瑞电气具备从终端感知、边缘计算到能效管理平台的产品生态体系&#xff0c;AcrelEMS-SW智慧水务能效管理平台通过在污水厂源、网、荷、储、充的各个关键节点安装保护、监测、分析、治理装置&#xff0c;用于监测污水厂能耗总量和能耗强度&#xff0c;重点监测主要…

vue3和vue2 语法差异之v-model详细说明

文章目录 0.前言1.参考文档2.详细说明介绍2.x 语法使用 v-bind.sync 3.x 语法v-model 参数v-model 修饰符 迁移策略 3.总结 0.前言 在 Vue 3 中&#xff0c;v-model 的使用方式与 Vue 2 有一些差异。下面是 Vue 3 中 v-model 的一些主要变化&#xff1a; 组件上的默认绑定&…

信捷 XD PLC 16位整数转换为双精度浮点数

完成16位整数转换为双精度浮点数&#xff0c;信捷XD PLC需要两个指令&#xff0c;逐步转换&#xff0c;一个指令搞不定。 具体的: 第1步&#xff1a;int16->int32 第2步&#xff1a;int32->Double 例子&#xff0c;比如说将D0转换成浮点数放到D100~D103

卷积操作后特征图尺寸,感受野,参数量的计算

文章目录 1、输出特征图的尺寸大小2、感受野的计算3、卷积核的参数量 1、输出特征图的尺寸大小 如果包含空洞卷积&#xff0c;即扩张率dilation rate不为1时&#xff1a; 2、感受野的计算 例如&#xff0c;图像经过两个3*3&#xff0c;步长为2的卷积后感受野为&#xff1a; co…

linux--epoll

epoll 参考文献 https://www.cnblogs.com/lojunren/p/3856290.html https://www.51cto.com/article/717096.html linux下的I/O复用epoll详解 要深刻理解epoll&#xff0c;首先得了解epoll的三大关键要素&#xff1a;mmap、红黑树、链表。 IO多路复用 首先需要了解什么是IO多…

如何增强企业合同管理数字化能力

随着科技的发展和信息化时代的来临&#xff0c;企业在合同管理方面面临着日益复杂的挑战。传统的合同管理方式已经无法满足企业对合同管理效率和准确性的需求。因此&#xff0c;增强企业合同管理的数字化能力成为迫切的任务。 下面是一些关键步骤&#xff0c;可以帮助企业有效…

java+springboot+mysql理发会员管理系统

项目介绍&#xff1a; 使用javaspringbootmysql开发的理发会员管理系统&#xff0c;系统包含超级管理员&#xff0c;系统管理员、客户、发型师角色&#xff0c;功能如下&#xff1a; 超级管理员&#xff1a;管理员管理&#xff1b;会员管理&#xff1b;发型师管理&#xff1b…

spring详解

spring是于2003年兴起的一款轻量级的&#xff0c;非侵入式的IOC和AOP的一站式的java开发框架&#xff0c;为简化企业级应用开发而生。 轻量级的&#xff1a;指的是spring核心功能的jar包不大。 非侵入式的&#xff1a;业务代码不需要继承或实现spring中任何的类或接口 IOC&…

jeecg导出excel文件时候是id,展示名称的处理方式

一.问题描述: 在jeecg3.5.3版本中,创建了一个基础表,并配置菜单,输入数据以后,如果需要导出数据,而且数据类型的展示页面类型是他表字段,这个情况下,直接使用jeecg默认功能,导出的excel并不会和页面一样,默认显示出来被选字段的字段名称。 例如:页面显示如下: 实…

Spring讲解和ioc用途及Web容器的整合

目录 一、Spring概述 ( 1 ) 背景 ( 2 ) 是什么 ( 3 ) 核心特性 二、Spring中的ioc 2.1 讲解 2.2 主要功能 2.3 实例演示 三、注入方式 3.1 set注入 3.2 构造注入 3.3 接口注入 四、Web容器整合 4.1 思考 4.2 实操 对我们的收获 一、Spring概述 ( 1 ) 背景 Spr…

春秋云镜 CVE-2020-17530

春秋云镜 CVE-2020-17530 S2-061 靶标介绍 对CVE-2019-0230的绕过&#xff0c;Struts2官方对CVE-2019-0230的修复方式是加强OGNL表达式沙盒&#xff0c;而CVE-2020-17530绕过了该沙盒。当对标签属性中的原始用户输入进行评估时&#xff0c;强制 OGNL 评估可能会导致远程代码执…

C语言实例_获取文件MD5值

一、MD5介绍 MD5&#xff08;Message Digest Algorithm 5&#xff09;是一种常用的哈希函数算法。将任意长度的数据作为输入&#xff0c;并生成一个唯一的、固定长度&#xff08;通常是128位&#xff09;的哈希值&#xff0c;称为MD5值。MD5算法以其高度可靠性和广泛应用而闻名…

15-生命周期

Vue生命周期 和 生命周期的四个阶段 Vue生命周期总结: 四个阶段,八个钩子 -> 三个常用 created,mounted,beforeDestroy 生命周期的钩子函数 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta name"…

智能报警系统:利用人工智能保障安全和及时应对危险

引言&#xff1a;随着人工智能的快速发展&#xff0c;智能报警系统成为了一种高效、及时应对危险和保障安全的重要工具。通过分析监控视频中的图像、声音以及其他传感器数据&#xff0c;人工智能可以自动检测和识别火灾、破坏、烟雾、异常温度等情况&#xff0c;并及时触发报警…

STM32单片机SPI通信实战:示例代码详解与应用案例

引言&#xff1a; 单片机SPI&#xff08;串行外设接口&#xff09;通信是一种常用的串行同步通信协议&#xff0c;用于单片机与外设之间的高速数据传输。SPI通信具有简单、高效、可靠等特点&#xff0c;在各种嵌入式系统中被广泛应用。本文将介绍单片机SPI通信的原理、配置和性…

WebRTC | 网络传输协议RTP与RTCP

目录 一、UDP与TCP 1. TCP 2. UDP 二、RTP 1. RTP协议头 &#xff08;1&#xff09;V&#xff08;Version&#xff09;字段 &#xff08;2&#xff09;P&#xff08;Padding&#xff09;字段 &#xff08;3&#xff09;X&#xff08;eXtension&#xff09;字段 &#x…

嵌入式笔试面试刷题(day11)

文章目录 前言一、字节流&#xff0c;数据报&#xff0c;报文二、makefile怎么引入库和模块三、多次free一块内存空间会怎么样四、字符操作函数越界会发生什么五、QT中一个信号可以连接多个槽函数吗六、QT中一个槽函数可以对应多个信号吗总结 前言 本篇文章继续刷题。 一、字…