利用React实现一个有点意思的电梯小程序.docx

利用React实现一个有点意思的电梯小程序.docx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多

利用React实现一个有点意思的电梯小程序

export{StyleLeftDoor,StyleRightDoor}

emotion语法可以通过函数来返回一个css属性,从而达到动态设置属性的目的,一对尖括号,其实也就是typescript中的泛型,代表是否传入toggle数据,接下来修改ElevatorLeftDoor.tsx和ElevatorRightDoor.tsx。如下:

import{StyleProps}from../type/style;

import{StyleLeftDoor}from./Door

exportinterfaceElevatorLeftDoorPropsextendsStyleProps{

toggle:boolean

constElevatorLeftDoor=(props:PartialElevatorLeftDoorProps)={

const{style,toggle}=props;

return(

StyleLeftDoor

import{StyleProps}from../type/style

import{StyleRightDoor}from./Door

exportinterfaceElevatorRightDoorPropsextendsStyleProps{

toggle:boolean

constElevatorRightDoor=(props:PartialElevatorRightDoorProps)={

const{style,toggle}=props;

return(

StyleRightDoor

修改电梯和电梯井组件

同样的我们也需要修改电梯组件和电梯井组件,如下所示:

importstyledfrom@emotion/styled

import{StyleProps}from../type/style;

importElevatorLeftDoorfrom./ElevatorLeftDoor

importElevatorRightDoorfrom./ElevatorRightDoor

constStyleElevator=styled.div`

height:98px;

background:url(/my-web-projects/js/26/img/6.jpg)center/coverno-repeat;

border:1pxsolidvar(--elevatorBorderColor--);

width:calc(100%-2px);

padding:1px;

transition-timing-function:ease-in-out;

position:absolute;

left:1px;

bottom:1px;

exportinterfaceElevatorPropsextendsStyleProps{

leftDoorStyle:StyleProps[style]

rightDoorStyle:StyleProps[style]

leftToggle:boolean

rightToggle:boolean

constElevator=(props:PartialElevatorProps)={

const{leftDoorStyle,rightDoorStyle,leftToggle,rightToggle}=props;

return(

StyleElevator

ElevatorLeftDoor

importstyledfrom@emotion/styled;

import{StyleProps}from../type/style;

importElevatorfrom./Elevator;

constStyleShaft=styled.div`

width:200px;

position:relative;

border-right:2pxsolidvar(--elevatorBorderColor--);

padding:1px;

exportinterfaceElevatorProps{

leftDoorStyle:StylePr

文档评论(0)

152****2468 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档