mybatis一对多,多对多关联关系

mybatis一对多,多对多关联关系

hibernate与mybatis的区别

1、 hibernate是全自动,而mybatis是半自动。

2、hibernate完全可以通过对象关系模型实现对数据库的操作,拥有完整的JavaBean对象与数据库的映射结构来自动生成sql。而mybatis仅有基本的字段映射,对象数据以及对象实际关系仍然需要通过手写sql来实现和管理。

我个人还是喜欢用mybatis,因为mybatis可以自己控制sql代码,而hibernate的sql是自动生成的,如果业务逻辑比较复杂容易把人绕晕

一对多:一个客户对应多个订单

多对一:多个订单对应一个客户(一个订单对应一个客户)

一对多

首先先用逆向生成工具生成t_hibernate_order、t_hibernate_order_item
这两张表对应的model与mapper
generatorConfig.xml
添加需要生成的表
在这里插入图片描述
OrderVo

package com.liuchunming.model.vo;

import com.liuchunming.model.Order;
import com.liuchunming.model.OrderItem;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 17:01
 */
public class OrderVo extends Order {
    public List<OrderItem> orderItems =new ArrayList<>();

    public List<OrderItem> getOrderItems() {
        return orderItems;
    }

    public void setOrderItems(List<OrderItem> orderItems) {
        this.orderItems = orderItems;
    }


}

OrderItemVo

package com.liuchunming.model.vo;

import com.liuchunming.model.Order;
import com.liuchunming.model.OrderItem;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 17:03
 */
public class OrderItemVo extends OrderItem {
    private Order order;

    public Order getOrder() {
        return order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }
}

OrderMapper.java
新添加查询方法
在这里插入图片描述
OrderMapper.xml
配置一对多映射关系
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.liuchunming.mapper.OrderMapper" >
  <resultMap id="BaseResultMap" type="com.liuchunming.model.Order" >
    <constructor >
      <idArg column="order_id" jdbcType="INTEGER" javaType="java.lang.Integer" />
      <arg column="order_no" jdbcType="VARCHAR" javaType="java.lang.String" />
    </constructor>
  </resultMap>

  <!--配置一对多   一的一方-->
  <resultMap id="OrderVoMap" type="com.liuchunming.model.vo.OrderVo">
    <result property="orderId" column="order_id"></result>
    <result property="orderNo" column="order_no"></result>
    <!--<result property="orderItems"></result>-->
    <collection property="orderItems" ofType="com.liuchunming.model.OrderItem">
      <result property="orderItemId" column="order_item_id"></result>
      <result property="productId" column="product_id"></result>
      <result property="quantity" column="quantity"></result>
      <result property="oid" column="oid"></result>
    </collection>
  </resultMap>

  <sql id="Base_Column_List" >
    order_id, order_no
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from t_hibernate_order
    where order_id = #{orderId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from t_hibernate_order
    where order_id = #{orderId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.liuchunming.model.Order" >
    insert into t_hibernate_order (order_id, order_no)
    values (#{orderId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.liuchunming.model.Order" >
    insert into t_hibernate_order
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="orderId != null" >
        order_id,
      </if>
      <if test="orderNo != null" >
        order_no,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="orderId != null" >
        #{orderId,jdbcType=INTEGER},
      </if>
      <if test="orderNo != null" >
        #{orderNo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.liuchunming.model.Order" >
    update t_hibernate_order
    <set >
      <if test="orderNo != null" >
        order_no = #{orderNo,jdbcType=VARCHAR},
      </if>
    </set>
    where order_id = #{orderId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.liuchunming.model.Order" >
    update t_hibernate_order
    set order_no = #{orderNo,jdbcType=VARCHAR}
    where order_id = #{orderId,jdbcType=INTEGER}
  </update>

  <select id="selectByOrderId" resultMap="OrderVoMap" parameterType="java.lang.Integer" >
    select * from t_hibernate_order o,t_hibernate_order_item oi where o.order_id=oi.oid
    and oi.oid=#{orderId}
  </select>

</mapper>

OrderItemMapper.java
在这里插入图片描述
OrderItemMapper.xml
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.liuchunming.mapper.OrderItemMapper" >
  <resultMap id="BaseResultMap" type="com.liuchunming.model.OrderItem" >
    <constructor >
      <idArg column="order_item_id" jdbcType="INTEGER" javaType="java.lang.Integer" />
      <arg column="product_id" jdbcType="INTEGER" javaType="java.lang.Integer" />
      <arg column="quantity" jdbcType="INTEGER" javaType="java.lang.Integer" />
      <arg column="oid" jdbcType="INTEGER" javaType="java.lang.Integer" />
    </constructor>
  </resultMap>

  <!--配置一对多   多的一方-->
  <resultMap id="OrderItemVoMap" type="com.liuchunming.model.vo.OrderItemVo">
    <result property="orderItemId" column="order_item_id"></result>
    <result property="productId" column="product_id"></result>
    <result property="quantity" column="quantity"></result>
    <result property="oid" column="oid"></result>
    <!--<result property="orderItems"></result>-->
    <association property="order" javaType="com.liuchunming.model.Order">
      <result property="orderId" column="order_id"></result>
      <result property="orderNo" column="order_no"></result>
    </association>
  </resultMap>

  <sql id="Base_Column_List" >
    order_item_id, product_id, quantity, oid
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from t_hibernate_order_item
    where order_item_id = #{orderItemId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from t_hibernate_order_item
    where order_item_id = #{orderItemId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.liuchunming.model.OrderItem" >
    insert into t_hibernate_order_item (order_item_id, product_id, quantity, 
      oid)
    values (#{orderItemId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{quantity,jdbcType=INTEGER}, 
      #{oid,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.liuchunming.model.OrderItem" >
    insert into t_hibernate_order_item
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="orderItemId != null" >
        order_item_id,
      </if>
      <if test="productId != null" >
        product_id,
      </if>
      <if test="quantity != null" >
        quantity,
      </if>
      <if test="oid != null" >
        oid,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="orderItemId != null" >
        #{orderItemId,jdbcType=INTEGER},
      </if>
      <if test="productId != null" >
        #{productId,jdbcType=INTEGER},
      </if>
      <if test="quantity != null" >
        #{quantity,jdbcType=INTEGER},
      </if>
      <if test="oid != null" >
        #{oid,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.liuchunming.model.OrderItem" >
    update t_hibernate_order_item
    <set >
      <if test="productId != null" >
        product_id = #{productId,jdbcType=INTEGER},
      </if>
      <if test="quantity != null" >
        quantity = #{quantity,jdbcType=INTEGER},
      </if>
      <if test="oid != null" >
        oid = #{oid,jdbcType=INTEGER},
      </if>
    </set>
    where order_item_id = #{orderItemId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.liuchunming.model.OrderItem" >
    update t_hibernate_order_item
    set product_id = #{productId,jdbcType=INTEGER},
      quantity = #{quantity,jdbcType=INTEGER},
      oid = #{oid,jdbcType=INTEGER}
    where order_item_id = #{orderItemId,jdbcType=INTEGER}
  </update>

  <select id="selectByOrderItemId" resultMap="OrderItemVoMap" parameterType="java.lang.Integer" >
    select * from t_hibernate_order o,t_hibernate_order_item oi where o.order_id=oi.oid
   and oi.order_item_id = #{orderItemId}
  </select>

</mapper>

OneToManyService

package com.liuchunming.service;

        import com.liuchunming.model.vo.OrderItemVo;
        import com.liuchunming.model.vo.OrderVo;

        import java.util.List;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 21:42
 */

public interface OneToManyService {
    List<OrderItemVo> selectByOrderItemId( Integer orderItemId);
    List<OrderVo> selectByOrderId(Integer orderId );
}

OneToManyServiceImpl

package com.liuchunming.service.impl;

import com.liuchunming.mapper.OrderItemMapper;
import com.liuchunming.mapper.OrderMapper;
import com.liuchunming.model.vo.OrderItemVo;
import com.liuchunming.model.vo.OrderVo;
import com.liuchunming.service.OneToManyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 22:04
 */
@Service
public class OneToManyServiceImpl implements OneToManyService {
    //将接口注入进来
    @Autowired
    private OrderMapper OrderMapper;
    @Autowired
    private OrderItemMapper OrderItemMapper;
    @Override
    public List<OrderItemVo> selectByOrderItemId(Integer orderItemId) {
        return OrderItemMapper.selectByOrderItemId(orderItemId);
    }

    @Override
    public List<OrderVo> selectByOrderId(Integer orderId) {
        return OrderMapper.selectByOrderId(orderId);
    }
}

测试
OneToManyServiceImplTest

package com.liuchunming.service.impl;

import com.liuchunming.SpringBaseTest;
import com.liuchunming.model.OrderItem;
import com.liuchunming.model.vo.OrderItemVo;
import com.liuchunming.model.vo.OrderVo;
import com.liuchunming.service.OneToManyService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import static org.junit.Assert.*;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 22:07
 */
public class OneToManyServiceImplTest extends SpringBaseTest {
    @Autowired
    private OneToManyService OneToManyService;
    @Test
    public void selectByOrderItemId() {
        List<OrderItemVo> orderItemVos = OneToManyService.selectByOrderItemId(36);
        OrderItemVo orderItemVo =orderItemVos.get(0);
        System.out.println(orderItemVo);
        System.out.println(orderItemVo.getOrder());
    }

    @Test
    public void selectByOrderId() {
        List<OrderVo> orderVos = OneToManyService.selectByOrderId(8);
        OrderVo orderVo=orderVos.get(0);
        System.out.println(orderVo);
        for (OrderItem orderItem : orderVo.getOrderItems()) {
            System.out.println(orderItem);
        }
    }
}

在这里插入图片描述

多对多

首先先用逆向生成工具生成t_hibernate_book、t_hibernate_book_category、t_hibernate_category,这两张表对应的model与mapper
HbookVo

package com.liuchunming.model.vo;

import com.liuchunming.model.Category;
import com.liuchunming.model.Hbook;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 22:21
 */
public class HbookVo extends Hbook {
    //创建关联关系
    private List<Category> categories=new ArrayList<>();

    public List<Category> getCategories() {
        return categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }
}

CategoryVo

package com.liuchunming.model.vo;

import com.liuchunming.model.Category;
import com.liuchunming.model.Hbook;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 22:23
 */
public class CategoryVo extends Category {
    private List<Hbook> hbooks=new ArrayList<>();

    public List<Hbook> getHbooks() {
        return hbooks;
    }

    public void setHbooks(List<Hbook> hbooks) {
        this.hbooks = hbooks;
    }
}

HbookMapper
添加方法
在这里插入图片描述
HbookMapper.xml
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.liuchunming.mapper.HbookMapper" >
  <resultMap id="BaseResultMap" type="com.liuchunming.model.Hbook" >
    <constructor >
      <idArg column="book_id" jdbcType="INTEGER" javaType="java.lang.Integer" />
      <arg column="book_name" jdbcType="VARCHAR" javaType="java.lang.String" />
      <arg column="price" jdbcType="REAL" javaType="java.lang.Float" />
    </constructor>
  </resultMap>

  <resultMap id="HbookVoMap" type="com.liuchunming.model.vo.HbookVo">
    <result property="bookId" column="book_id"></result>
    <result property="bookName" column="book_name"></result>
    <result property="price" column="price"></result>
    <!--<result property="orderItems"></result>-->
    <collection property="categories" ofType="com.liuchunming.model.Category">
      <result property="categoryId" column="category_id"></result>
      <result property="categoryName" column="category_name"></result>
    </collection>
  </resultMap>

  <sql id="Base_Column_List" >
    book_id, book_name, price
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from t_hibernate_book
    where book_id = #{bookId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from t_hibernate_book
    where book_id = #{bookId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.liuchunming.model.Hbook" >
    insert into t_hibernate_book (book_id, book_name, price
      )
    values (#{bookId,jdbcType=INTEGER}, #{bookName,jdbcType=VARCHAR}, #{price,jdbcType=REAL}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.liuchunming.model.Hbook" >
    insert into t_hibernate_book
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="bookId != null" >
        book_id,
      </if>
      <if test="bookName != null" >
        book_name,
      </if>
      <if test="price != null" >
        price,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="bookId != null" >
        #{bookId,jdbcType=INTEGER},
      </if>
      <if test="bookName != null" >
        #{bookName,jdbcType=VARCHAR},
      </if>
      <if test="price != null" >
        #{price,jdbcType=REAL},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.liuchunming.model.Hbook" >
    update t_hibernate_book
    <set >
      <if test="bookName != null" >
        book_name = #{bookName,jdbcType=VARCHAR},
      </if>
      <if test="price != null" >
        price = #{price,jdbcType=REAL},
      </if>
    </set>
    where book_id = #{bookId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.liuchunming.model.Hbook" >
    update t_hibernate_book
    set book_name = #{bookName,jdbcType=VARCHAR},
      price = #{price,jdbcType=REAL}
    where book_id = #{bookId,jdbcType=INTEGER}
  </update>

  <select id="selectByBid" resultMap="HbookVoMap" parameterType="java.lang.Integer" >
    select * from t_hibernate_book b,t_hibernate_book_category bc,t_hibernate_category c where b.book_id=bc.bid
     and  bc.cid=c.category_id and b.book_id=#{bid}
  </select>

</mapper>

CategoryMapper
在这里插入图片描述
CategoryMapper.xml
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.liuchunming.mapper.CategoryMapper" >
  <resultMap id="BaseResultMap" type="com.liuchunming.model.Category" >
    <constructor >
      <idArg column="category_id" jdbcType="INTEGER" javaType="java.lang.Integer" />
      <arg column="category_name" jdbcType="VARCHAR" javaType="java.lang.String" />
    </constructor>
  </resultMap>

  <resultMap id="CategoryVoMap" type="com.liuchunming.model.vo.CategoryVo">
    <result property="categoryId" column="category_id"></result>
    <result property="categoryName" column="category_name"></result>
    <!--<result property="orderItems"></result>-->
    <collection property="hbooks" ofType="com.liuchunming.model.Hbook">
      <result property="bookId" column="book_id"></result>
      <result property="bookName" column="book_name"></result>
      <result property="price" column="price"></result>
    </collection>
  </resultMap>

  <sql id="Base_Column_List" >
    category_id, category_name
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from t_hibernate_category
    where category_id = #{categoryId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from t_hibernate_category
    where category_id = #{categoryId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.liuchunming.model.Category" >
    insert into t_hibernate_category (category_id, category_name)
    values (#{categoryId,jdbcType=INTEGER}, #{categoryName,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.liuchunming.model.Category" >
    insert into t_hibernate_category
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="categoryId != null" >
        category_id,
      </if>
      <if test="categoryName != null" >
        category_name,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="categoryId != null" >
        #{categoryId,jdbcType=INTEGER},
      </if>
      <if test="categoryName != null" >
        #{categoryName,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.liuchunming.model.Category" >
    update t_hibernate_category
    <set >
      <if test="categoryName != null" >
        category_name = #{categoryName,jdbcType=VARCHAR},
      </if>
    </set>
    where category_id = #{categoryId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.liuchunming.model.Category" >
    update t_hibernate_category
    set category_name = #{categoryName,jdbcType=VARCHAR}
    where category_id = #{categoryId,jdbcType=INTEGER}
  </update>

  <select id="selectBycid" resultMap="CategoryVoMap" parameterType="java.lang.Integer" >
    select * from t_hibernate_book b,t_hibernate_book_category bc,t_hibernate_category c where b.book_id=bc.bid
     and  bc.cid=c.category_id and c.category_id=#{cid}
  </select>

</mapper>

ManyToManyService

package com.liuchunming.service;

import com.liuchunming.model.vo.CategoryVo;
import com.liuchunming.model.vo.HbookVo;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 22:49
 */
public interface ManyToManyService {
    CategoryVo selectBycid(Integer cid);
    HbookVo selectByBid( Integer bid);
}

ManyToManyServiceImpl

package com.liuchunming.service.impl;

import com.liuchunming.mapper.CategoryMapper;
import com.liuchunming.mapper.HbookMapper;
import com.liuchunming.model.vo.CategoryVo;
import com.liuchunming.model.vo.HbookVo;
import com.liuchunming.service.ManyToManyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 22:50
 */
@Service
public class ManyToManyServiceImpl implements ManyToManyService {
    @Autowired
    private HbookMapper hbookMapper;
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public CategoryVo selectBycid(Integer cid) {
        return categoryMapper.selectBycid(cid);
    }

    @Override
    public HbookVo selectByBid(Integer bid) {
        return hbookMapper.selectByBid(bid);
    }
}

ManyToManyServiceImplTest

package com.liuchunming.service.impl;

import com.liuchunming.SpringBaseTest;
import com.liuchunming.model.Category;
import com.liuchunming.model.Hbook;
import com.liuchunming.model.vo.CategoryVo;
import com.liuchunming.model.vo.HbookVo;
import com.liuchunming.service.ManyToManyService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author liuchunming
 * @site www.liuchunming.com
 * @company xxx公司
 * @create  2020-10-21 22:53
 */
public class ManyToManyServiceImplTest extends SpringBaseTest {
    @Autowired
    private ManyToManyService manyToManyService;
    @Test
    public void selectBycid() {
        CategoryVo categoryVo = this.manyToManyService.selectBycid(8);
        System.out.println(categoryVo);
        for (Hbook hbook : categoryVo.getHbooks()) {
            System.out.println(hbook);
        }

    }

    @Test
    public void selectByBid() {
        HbookVo hbookVo = manyToManyService.selectByBid(8);
        System.out.println(hbookVo);
        for (Category category : hbookVo.getCategories()) {
            System.out.println(category);
        }
    }
}

测试
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用 JavaScript 编写的记忆游戏(附源代码)   项目:JavaScript 记忆游戏(附源代码) 记忆检查游戏是一个使用 HTML5、CSS 和 JavaScript 开发的简单项目。这个游戏是关于测试你的短期 记忆技能。玩这个游戏 时,一系列图像会出现在一个盒子形状的区域中 。玩家必须找到两个相同的图像并单击它们以使它们消失。 如何运行游戏? 记忆游戏项目仅包含 HTML、CSS 和 JavaScript。谈到此游戏的功能,用户必须单击两个相同的图像才能使它们消失。 点击卡片或按下键盘键,通过 2 乘 2 旋转来重建鸟儿对,并发现隐藏在下面的图像! 如果翻开的牌面相同(一对),您就赢了,并且该对牌将从游戏中消失! 否则,卡片会自动翻面朝下,您需要重新尝试! 该游戏包含大量的 javascript 以确保游戏正常运行。 如何运行该项目? 要运行此游戏,您不需要任何类型的本地服务器,但需要浏览器。我们建议您使用现代浏览器,如 Google Chrome 和 Mozilla Firefox, 以获得更好、更优化的游戏体验。要玩游戏,首先,通过单击 memorygame-index.html 文件在浏览器中打开游戏。 演示: 该项目为国外大神项目,可以作为毕业设计的项目,也可以作为大作业项目,不用担心代码重复,设计重复等,如果需要对项目进行修改,需要具备一定基础知识。 注意:如果装有360等杀毒软件,可能会出现误报的情况,源码本身并无病毒,使用源码时可以关闭360,或者添加信任。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值