百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术文章 > 正文

HTML+JavaScript案例分享: 打造经典俄罗斯方块,详解实现全过程

myzbx 2024-12-11 15:56 37 浏览

大家好,我是魏大帅,今天教大家一个装[啤酒]的方法。你说你不懂前端,没关系我教你。打开你的电脑,新建一个txt文档,把我文章最后面的完整代码复制到文档里面,然后把txt文档的后缀名改成.html 就ok啦,你可以直接把这个html文件发给你朋友,说这是哥们我做的,[给力]不!

哈哈,前面这段纯属开玩笑的,主要还是给各位前端开发,或者想从事前端开发的帅哥美女们,一个可以借鉴的案例。有大神觉得自己有更厉害的案例,也可以告诉我,我也学习学习,咱们互相学习互相进步。话不多说,上干货!

这是俄罗斯方块的效果图:

一、游戏界面与布局

我们最先借助 HTML 和 CSS 来打造游戏的界面。这页面主要涵盖了一个游戏区域,也就是 (<canvas>元素),还有一个包含“开始游戏”按钮以及得分展示的区域。

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>俄罗斯方块</title>
    <style>
        body {
            background-color: #e0e0e0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            overflow: hidden;
        }

        #game-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        #game-board {
            border: 3px solid #333;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
            width: 350px;
            height: 700px;
        }

        #startButtonAndScore {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 20px;
            margin-top: 15px;
        }

        #startButton {
            padding: 12px 20px;
            font-size: 16px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        #startButton:hover {
            background-color: #45a049;
        }

        #scoreContainer {
            font-size: 18px;
            font-weight: bold;
            color: #555;
        }
    </style>
</head>

<body>
    <div id="game-container">
        <canvas id="game-board" width="350" height="700"></canvas>
        <div id="startButtonAndScore">
            <button id="startButton">开始游戏</button>
            <div id="scoreContainer">得分:0</div>
        </div>
    </div>
    <script>
        // 以下是 JavaScript 代码部分
    </script>
</body>

</html>

二、游戏逻辑实现

1. 定义方块形状和颜色

我们先把各种各样可能会出现的方块形状和相对应的颜色给定义好了。

const shapes = [
    [
        [1, 1],
        [1, 1]
    ],
    [
        [0, 1, 0],
        [1, 1, 1]
    ],
    [
        [1, 0],
        [1, 0],
        [1, 1]
    ],
    [
        [0, 1],
        [0, 1],
        [1, 1]
    ],
    [
        [1, 1, 1],
        [0, 1, 0]
    ],
    [
        [1, 1, 0],
        [0, 1, 1]
    ],
    [
        [0, 1, 1],
        [1, 1, 0]
    ]
];
// 不同形状对应的颜色数组
const colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'cyan'];

2. 游戏状态变量

设置了一连串的游戏状态变量,用来追踪游戏板的状况、当下正在下落的方块、所在位置、得分情况,还有游戏是不是结束了之类的信息。

let board = []; // 游戏板状态,二维数组表示游戏区域的方块分布
let currentShape = null; // 当前正在下落的形状
let currentShapeColor = null; // 当前形状的颜色
let currentX = 0; // 当前形状在游戏板上的横坐标
let currentY = 0; // 当前形状在游戏板上的纵坐标
let intervalId = null; // 游戏循环的定时器 ID
let score = 0; // 玩家得分
let gameOver = false; // 游戏是否结束的标志

3. 创建游戏板

用一个函数来把游戏板初始化,把每个格子都初始化成 0 ,意思就是都为空。

function createBoard() {
    // 遍历每一行
    for (let i = 0; i < 20; i++) {
        board[i] = [];
        // 遍历每一列,将每个格子初始化为 0
        for (let j = 0; j < 10; j++) {
            board[i][j] = 0;
        }
    }
}

4. 绘制游戏板

这个函数负责在<canvas>上面画游戏板和当下正在掉落的方块。要是格子里有方块,那就依据方块的颜色把对应的区域填满。

function drawBoard() {
    const canvas = document.getElementById('game-board');
    const ctx = canvas.getContext('2d');
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    // 遍历游戏板的每一行和每一列
    for (let i = 0; i < 20; i++) {
        for (let j = 0; j < 10; j++) {
            if (board[i][j] > 0) {
                // 根据格子中的值确定颜色并填充方块
                ctx.fillStyle = colors[board[i][j] - 1];
                ctx.fillRect(j * (canvas.width / 10), i * (canvas.height / 20), canvas.width / 10, canvas.height / 20);
            }
        }
    }
    // 如果有正在下落的方块且游戏未结束,绘制该方块
    if (currentShape &&!gameOver) {
        for (let i = 0; i < currentShape.length; i++) {
            for (let j = 0; j < currentShape[i].length; j++) {
                if (currentShape[i][j]) {
                    ctx.fillStyle = currentShapeColor;
                    ctx.fillRect((currentX + j) * (canvas.width / 10), (currentY + i) * (canvas.height / 20), canvas.width / 10, canvas.height / 20);
                }
            }
        }
    }
}

5. 生成新的形状

随便挑一个方块的形状和颜色,把它的初始位置定在游戏板中央靠上的地方。

function newShape() {
    const randomShapeIndex = Math.floor(Math.random() * shapes.length);
    // 随机选择一个形状并设置为当前形状
    currentShape = shapes[randomShapeIndex];
    // 选择对应的颜色
    currentShapeColor = colors[randomShapeIndex];
    // 计算初始横坐标使其在游戏板中央
    currentX = Math.floor(10 / 2 - currentShape[0].length / 2);
    currentY = 0;
}

6. 检查是否可以移动

判断一下当前的方块能不能在给定的那个方向上移动,如果移动后的位置超过了游戏板的边界,或者已经有别的方块占着了,那就不能移动。

function canMove(x, y) {
    for (let i = 0; i < currentShape.length; i++) {
        for (let j = 0; j < currentShape[i].length; j++) {
            if (currentShape[i][j]) {
                const newX = currentX + j + x;
                const newY = currentY + i + y;
                // 检查新位置是否合法
                if (newX < 0 || newX >= 10 || newY >= 20 || (newY >= 0 && board[newY][newX])) {
                    return false;
                }
            }
        }
    }
    return true;
}

7. 移动形状

要是能移动,那就把方块的位置更新一下。

function moveShape(x, y) {
    if (canMove(x, y)) {
        for (let i = 0; i < currentShape.length; i++) {
            for (let j = 0; j < currentShape[i].length; j++) {
                if (currentShape[i][j]) {
                    // 将当前位置在游戏板上的值设置为 0,表示该位置不再有方块
                    board[currentY + i][currentX + j] = 0;
                }
            }
        }
        // 更新横坐标和纵坐标
        currentX += x;
        currentY += y;
    }
}

8. 旋转形状

用转换矩阵的办法来让方块旋转。先弄出一个新的形状的数组,然后看看旋转后的形状能不能放在游戏板上,如果能,就把当前的形状更新成旋转后的形状。

function rotateShape() {
    const newShape = [];
    for (let i = 0; i < currentShape[0].length; i++) {
        newShape[i] = [];
        for (let j = 0; j < currentShape.length; j++) {
            // 实现形状的旋转
            newShape[i][j] = currentShape[currentShape.length - 1 - j][i];
        }
    }
    if (canMove(0, 0)) {
        for (let i = 0; i < currentShape.length; i++) {
            for (let j = 0; j < currentShape[i].length; j++) {
                if (currentShape[i][j]) {
                    board[currentY + i][currentX + j] = 0;
                }
            }
        }
        // 更新当前形状为旋转后的形状
        currentShape = newShape;
    }
}

9. 固定形状到游戏板

判断一下方块是不是该停止往下落了,如果是,那就把方块固定在游戏板上,再检查检查有没有完整的行能消除掉。要是有,就把这些行删掉,得分也增加,然后生成新的方块。要是方块还能往下落,那就接着往下落。

function fixShape() {
    let shouldStop = false;
    for (let i = 0; i < currentShape.length; i++) {
        for (let j = 0; j < currentShape[i].length; j++) {
            if (currentShape[i][j]) {
                const newY = currentY + i;
                if (newY + 1 >= 20 || (newY + 1 >= 0 && board[newY + 1][currentX + j])) {
                    shouldStop = true;
                    break;
                }
            }
        }
        if (shouldStop) break;
    }
    if (shouldStop) {
        for (let i = 0; i < currentShape.length; i++) {
            for (let j = 0; j < currentShape[i].length; j++) {
                if (currentShape[i][j]) {
                    if (currentY + i < 20 && currentX + j >= 0 && currentX + j < 10 && board[currentY + i][currentX + j] === 0) {
                        board[currentY + i][currentX + j] = colors.indexOf(currentShapeColor) + 1;
                    }
                }
            }
        }
        removeFullLines();
        newShape();
        checkGameOver();
    } else {
        moveShape(0, 1);
    }
}

10. 检查是否有满行并删除

把游戏板的每一行都走一遍,检查检查有没有完整的行。要是有,就把那行删掉,在顶部加上一行空的,同时得分也增加。

function removeFullLines() {
    let linesRemoved = 0;
    for (let i = board.length - 1; i >= 0; i--) {
        if (board[i].every(cell => cell > 0)) {
            board.splice(i, 1);
            board.unshift(new Array(10).fill(0));
            linesRemoved++;
        }
    }
    if (linesRemoved > 0) {
        score += linesRemoved * 10;
        document.getElementById('scoreContainer').innerText = '得分:' + score;
    }
}

11. 检查游戏是否结束

检查游戏板的第一行有没有方块,要是有,那游戏就结束啦

function checkGameOver() {
    for (let j = 0; j < 10; j++) {
        if (board[0][j] > 0) {
            gameOver = true;
            clearInterval(intervalId);
            alert('游戏结束!你的得分是:' + score);
            break;
        }
    }
}

12. 游戏循环

游戏循环的那个函数不停地查看方块能不能下落,要是不能下落或者游戏已经结束了,那就调用 fixShape 函数把方块给定住;要是能下落,就让方块接着往下落,并且把游戏板给画出来。

function gameLoop() {
    if (!canMove(0, 1) || gameOver) {
        fixShape();
    } else {
        moveShape(0, 1);
    }
    drawBoard();
}

13. 开始游戏

要是点击“开始游戏”这个按钮,就调用这个函数。要是已经有游戏正在进行当中,那就先把旧游戏停下,接着把游戏状态重置了,创建一个新的游戏板,生成新的方块,启动游戏循环,然后把得分显示也更新一下。

function startGame() {
    if (intervalId) {
        clearInterval(intervalId);
    }
    board = [];
    currentShape = null;
    currentShapeColor = null;
    currentX = 0;
    currentY = 0;
    score = 0;
    gameOver = false;
    createBoard();
    newShape();
    intervalId = setInterval(gameLoop, 1000);
    document.getElementById('scoreContainer').innerText = '得分:' + score;
}

14. 按键事件处理

咱们监听键盘事件,要是按了左、右、下、上箭头键,那就分别对应着方块的左移、右移、下落和旋转这些操作。要是游戏已经结束了,那就不响应按键事件。

document.addEventListener('keydown', event => {
    if (gameOver) return;
    switch (event.keyCode) {
        case 37: // 左箭头
            moveShape(-1, 0);
            break;
        case 39: // 右箭头
            moveShape(1, 0);
            break;
        case 40: // 下箭头
            moveShape(0, 1);
            break;
        case 38: // 上箭头
            rotateShape();
            break;
    }
    drawBoard();
});

三、完整代码

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>俄罗斯方块</title>
  <style>
    body {
      background-color: #e0e0e0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100vh;
      overflow: hidden;
    }

    #game-container {
      background-color: #fff;
      padding: 20px;
      border-radius: 10px;
      box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    #game-board {
      border: 3px solid #333;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
      width: 350px;
      height: 700px;
    }

    #startButtonAndScore {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 20px;
      margin-top: 15px;
    }

    #startButton {
      padding: 12px 20px;
      font-size: 16px;
      background-color: #4CAF50;
      color: white;
      border: none;
      border-radius: 8px;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }

    #startButton:hover {
      background-color: #45a049;
    }

    #scoreContainer {
      font-size: 18px;
      font-weight: bold;
      color: #555;
    }
  </style>
</head>

<body>
  <div id="game-container">
    <canvas id="game-board" width="350" height="700"></canvas>
    <div id="startButtonAndScore">
      <button id="startButton">开始游戏</button>
      <div id="scoreContainer">得分:0</div>
    </div>
  </div>
  <script>
    // 定义方块形状和颜色数组
    const shapes = [
      [
        [1, 1],
        [1, 1]
      ],
      [
        [0, 1, 0],
        [1, 1, 1]
      ],
      [
        [1, 0],
        [1, 0],
        [1, 1]
      ],
      [
        [0, 1],
        [0, 1],
        [1, 1]
      ],
      [
        [1, 1, 1],
        [0, 1, 0]
      ],
      [
        [1, 1, 0],
        [0, 1, 1]
      ],
      [
        [0, 1, 1],
        [1, 1, 0]
      ]
    ];
    const colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'cyan'];

    // 游戏状态变量
    let board = []; // 游戏板状态
    let currentShape = null; // 当前正在下落的形状
    let currentShapeColor = null; // 当前形状的颜色
    let currentX = 0; // 当前形状的横坐标
    let currentY = 0; // 当前形状的纵坐标
    let intervalId = null; // 游戏循环的定时器 ID
    let score = 0; // 得分
    let gameOver = false; // 游戏是否结束标志

    // 创建游戏板
    function createBoard() {
      for (let i = 0; i < 20; i++) {
        board[i] = [];
        for (let j = 0; j < 10; j++) {
          board[i][j] = 0;
        }
      }
    }

    // 绘制游戏板
    function drawBoard() {
      const canvas = document.getElementById('game-board');
      const ctx = canvas.getContext('2d');
      ctx.clearRect(0, 0, canvas.width, canvas.height);
      for (let i = 0; i < 20; i++) {
        for (let j = 0; j < 10; j++) {
          if (board[i][j] > 0) {
            ctx.fillStyle = colors[board[i][j] - 1];
            ctx.fillRect(j * (canvas.width / 10), i * (canvas.height / 20), canvas.width / 10, canvas.height / 20);
          }
        }
      }
      if (currentShape &&!gameOver) {
        for (let i = 0; i < currentShape.length; i++) {
          for (let j = 0; j < currentShape[i].length; j++) {
            if (currentShape[i][j]) {
              ctx.fillStyle = currentShapeColor;
              ctx.fillRect((currentX + j) * (canvas.width / 10), (currentY + i) * (canvas.height / 20), canvas.width / 10, canvas.height / 20);
            }
          }
        }
      }
    }

    // 生成新的形状
    function newShape() {
      const randomShapeIndex = Math.floor(Math.random() * shapes.length);
      currentShape = shapes[randomShapeIndex];
      currentShapeColor = colors[randomShapeIndex];
      currentX = Math.floor(10 / 2 - currentShape[0].length / 2);
      currentY = 0;
    }

    // 检查是否可以移动
    function canMove(x, y) {
      for (let i = 0; i < currentShape.length; i++) {
        for (let j = 0; j < currentShape[i].length; j++) {
          if (currentShape[i][j]) {
            const newX = currentX + j + x;
            const newY = currentY + i + y;
            if (newX < 0 || newX >= 10 || newY >= 20 || (newY >= 0 && board[newY][newX])) {
              return false;
            }
          }
        }
      }
      return true;
    }

    // 移动形状
    function moveShape(x, y) {
      if (canMove(x, y)) {
        for (let i = 0; i < currentShape.length; i++) {
          for (let j = 0; j < currentShape[i].length; j++) {
            if (currentShape[i][j]) {
              board[currentY + i][currentX + j] = 0;
            }
          }
        }
        currentX += x;
        currentY += y;
      }
    }

    // 旋转形状
    function rotateShape() {
      const newShape = [];
      for (let i = 0; i < currentShape[0].length; i++) {
        newShape[i] = [];
        for (let j = 0; j < currentShape.length; j++) {
          newShape[i][j] = currentShape[currentShape.length - 1 - j][i];
        }
      }
      if (canMove(0, 0)) {
        for (let i = 0; i < currentShape.length; i++) {
          for (let j = 0; j < currentShape[i].length; j++) {
            if (currentShape[i][j]) {
              board[currentY + i][currentX + j] = 0;
            }
          }
        }
        currentShape = newShape;
      }
    }

    // 固定形状到游戏板
    function fixShape() {
      let shouldStop = false;
      for (let i = 0; i < currentShape.length; i++) {
        for (let j = 0; j < currentShape[i].length; j++) {
          if (currentShape[i][j]) {
            const newY = currentY + i;
            if (newY + 1 >= 20 || (newY + 1 >= 0 && board[newY + 1][currentX + j])) {
              shouldStop = true;
              break;
            }
          }
        }
        if (shouldStop) break;
      }
      if (shouldStop) {
        for (let i = 0; i < currentShape.length; i++) {
          for (let j = 0; j < currentShape[i].length; j++) {
            if (currentShape[i][j]) {
              if (currentY + i < 20 && currentX + j >= 0 && currentX + j < 10 && board[currentY + i][currentX + j] === 0) {
                board[currentY + i][currentX + j] = colors.indexOf(currentShapeColor) + 1;
              }
            }
          }
        }
        removeFullLines();
        newShape();
        checkGameOver();
      } else {
        moveShape(0, 1);
      }
    }

    // 检查是否有满行并删除
    function removeFullLines() {
      let linesRemoved = 0;
      for (let i = board.length - 1; i >= 0; i--) {
        if (board[i].every(cell => cell > 0)) {
          board.splice(i, 1);
          board.unshift(new Array(10).fill(0));
          linesRemoved++;
        }
      }
      if (linesRemoved > 0) {
        score += linesRemoved * 10;
        document.getElementById('scoreContainer').innerText = '得分:' + score;
      }
    }

    // 检查游戏是否结束
    function checkGameOver() {
      for (let j = 0; j < 10; j++) {
        if (board[0][j] > 0) {
          gameOver = true;
          clearInterval(intervalId);
          alert('游戏结束!你的得分是:' + score);
          break;
        }
      }
    }

    // 游戏循环
    function gameLoop() {
      if (!canMove(0, 1) || gameOver) {
        fixShape();
      } else {
        moveShape(0, 1);
      }
      drawBoard();
    }

    // 开始游戏
    function startGame() {
      if (intervalId) {
        // 如果已经有游戏在进行,先停止旧的游戏
        clearInterval(intervalId);
      }
      // 重置游戏状态
      board = [];
      currentShape = null;
      currentShapeColor = null;
      currentX = 0;
      currentY = 0;
      score = 0;
      gameOver = false;
      createBoard();
      newShape();
      intervalId = setInterval(gameLoop, 1000);
      document.getElementById('scoreContainer').innerText = '得分:' + score;
    }

    document.getElementById('startButton').addEventListener('click', startGame);

    // 按键事件处理
    document.addEventListener('keydown', event => {
      if (gameOver) return;
      switch (event.keyCode) {
        case 37: // 左箭头
          moveShape(-1, 0);
          break;
        case 39: // 右箭头
          moveShape(1, 0);
          break;
        case 40: // 下箭头
          moveShape(0, 1);
          break;
        case 38: // 上箭头
          rotateShape();
          break;
      }
      drawBoard();
    });
  </script>
</body>

</html>

凭借上面这些代码,咱们顺利做成了一个挺简单的俄罗斯方块游戏。

希望这篇文章能对你有所帮助![赞][比心]

相关推荐

JMeter:执行顺序与作用域(jmeter顺序执行怎么设置)

一、执行顺序类似于运算符或操作符的优先级,当JMeter测试中包含多个不同的元素时,哪些元素先执行,哪些元素后执行,并不是严格按照它们出现的先后顺序依次有序执行的,而是会遵循一定的内部规则,我们称之为...

彻底搞懂C语言指针(c语言 指针用法)

指针是C语言的难点,本篇文章总结一下各类指针的用法。指针是个变量,它存储的是变量的地址,这个地址指向哪里,取决于指针的类型,指针类型包括以下几种:基本类型指针数组类型指针函数类型指针结构体类型指针联合...

Excel运算符相关知识点分享(excel运算符有哪些类型)

在Excel中,运算符主要用于执行各种计算和逻辑操作主要分为以下四类1.比较运算符在Excel中,比较运算符用于比较两个值,并返回逻辑结果TRUE(真)或FALSE(假)。它们常用于条件判...

Python编程基础:运算符的优先级(python运算符优先级记忆口诀)

多个运算符同时出现在一个表达式中时,先执行哪个,后执行哪个,这就涉及运算符的优先级。如数学表达式,有+、-、×、÷、()等,优先级顺序是()、×、÷、+、-,如5+(5-3)×4÷2,先计算(5-3)...

吊打面试官(四)--Java语法基础运算符一文全掌握

简介本文介绍了Java运算符相关知识,包含运算规则,运算符使用经验,特殊运算符注意事项等,全文5400字。熟悉了这些内容,在运算符这块就可以吊打面试官了。Java运算符的规则与特性1.贪心规则(Ma...

C语言零基础教学-3-运算符与表达式

同学们好,今天学习c元基础知识第三讲:运算符与表达式。本节内容将学习算数运算符与算数表达式。·至臻至减运算符、赋值运算符、逗号运算符、求至结运算符。→首先学习算数运算符,它包含加减乘除求余数正负。比如...

Python运算符优先级终极指南:避免表达式计算的陷阱

混合表达式中的运算符优先级当Python表达式中同时出现算术运算符、布尔运算符和比较运算符时,计算顺序由运算符优先级决定:算术运算符(最高优先级)包括:乘方(**)、乘除(*,/,//,%)、加...

Python自动化办公应用学习笔记12——运算符及运算符优先级

一、运算符1.算术运算符:运算符名称描述示例+加数值相加10+3=13-减数值相减10-3=7*乘数值相乘10*3=30/除浮点数除法10/3≈3.33//整除向下...

python3-运算符优先级(python运算符优先级最高)

#挑战30天在头条写日记#Python运算符优先级以下列出了从最高到最低优先级的所有运算符,相同单元格内的运算符具有相同优先级。运算符均指二元运算,除非特别指出。相同单元格内的运算符从左至右分组...

Java运算符优先级表(java语言中运算符的优先级)

Java语言中有很多运算符,由于运算符优先级的问题经常会导致程序出现意想不到的结果,为了避免程序可能由于运算顺序而导致一系列的问题,Java初学者需应尽可能掌握这些运算符规律图示给大家详细介绍了运算符...

Excel公式中运算符类型及优先顺序

在Excel中公式中,用到的一些运算符是有优先计算顺序的,详见下图。下面我们简单介绍一下这些运算符的使用方法。说明:Excel中所有公式及运算符,都需要在英文输入法半角状态输入,不要输入中文字符或者全...

JavaScript基础知识14——运算符:逻辑运算符,运算符优先级

哈喽,大家好,我是雷工!一、逻辑运算符1、概念:在程序中用来连接多个比较条件时候使用的符号。2、应用场景:在程序中用来连接多个比较条件时候使用。3、逻辑运算符符号:4、代码演示逻辑运算符的使用:逻辑...

认识Excel中的运算符(excel中的运算符包括在哪里)

Excel中,函数与公式无疑是最具有魅力的功能之一。使用函数与公式,能帮助用户完成多种要求的数据运算、汇总、提取等工作。函数与公式同数据验证功能相结合,能限制数据的输入内容或类型,还可以制作动态更新...

JavaScript 中的运算符优先级(javascript中的运算符分为哪几种?)

#寻找热爱表达的你#新人求关注,点击右上角↗关注,博主日更,全年无休,您的关注是我的最大的更新的动力~感谢大家了运算符优先级在JavaScript中是指决定表达式中不同操作符执行顺序的规...

从几个细节问题出发,如何写好产品需求文档?

来人人都是产品经理【起点学院】,BAT实战派产品总监手把手系统带你学产品、学运营。这篇文章暂时不讨论什么是需求文档,也不强调需求文档的重要性等等,就简单地从各种细节问题出发如何写好一份需求文档。一份好...