Haven't found a job yet? Do you know these six front-end interview questions?

Haven't found a job yet? Do you know these six front-end interview questions?

1. Briefly describe the principle of deep cloning

深克隆就是将引用类型的值全部拷贝一份,形成一个新的引用类型,这样就不会发生引用错乱的问题,
首先判断执行对象的类型是数组、对象或是普通类型,通过for in遍历数组或者对象,
判断value的类型 ,如果是对象类型那么就递归再次执行深克隆,直到全是普通类型。

2. Implement token login authentication

  用户登录账户,后端校验数据库,如果账号密码正确那么会用jwt.sign将用户信息以对称加密的方式生成一个
  字符串发送到前段,前端进行存储,在进行需要登录验证的跳转时需要携带这个数据进行验证,

The backend uses jwt.vertify to decrypt, and then compares the database to find the existence of the user.

3. The difference between component children render in react routing

 component引用组件可以写成类的形式也可以写成返回值的形式,当路由匹配时才能渲染。
 render 使用组件的时候需要写成返回值的形式,当路由匹配时才能渲染。
 children使用组件的时候需要写成返回值的形式,无论路由是否匹配都能渲染,不过如果路径不一致,match为null。

4. Several ways for react routing to transmit and obtain routing information

传参 query + location.search
  this.props.history.push('/movie?id=2')
  接收参数用this.props.location.search
传参2 动态路由 + match.params
  path/:type
  this.props.history.push('/movie/2')
  接收参数用this.props.match.params.type
传参3 state + location.state
  this.props.history.push('/movie',{name:'haha'})
  接收参数用this.props.location.state.name

5. The difference between route jump switchTab navigateTo redirectTo in the mini program

switchTab

Jump to the tabBar page and close all other non-tabBar pages

navigateTo

Keep the current page and jump to a page within the app. But you cannot jump to the tabbar page. Use wx.navigateBack to return to the original page. The page stack in the mini program can have up to ten levels, similar to history.push.

redirectTo

Close the current page and jump to a page within the app. But jumping to the tabbar page is not allowed. The function is equivalent to history.repalce. There is a comic page in my project, which involves a large number of previous and next page operations. If redirectto is used or not, it will be recorded every time. When going back, you cannot go back to it all at once. On other pages, the user experience is not very good.

6. How to solve the highlighting problem of vue tabbar after refreshing. The implementation principle of tabbar in mini program

	vuetabbar在页面刷新后,active会清零,出现下面的高亮和页面不匹配的情况,解决方法第一种是
tabbar中加入route属性,开启路由模式,但是有一个弊端就是如果涉及到页面内有二级路由,那么将
会全部高亮失效,因此有二级路由的时候不推荐使用route。第二种是在每次进入的页面中设置meta,
然后给每一个router设置name属性与active相对应,根绝页面路由的meta属性,修改active值使其与
name属性匹配。小程序的tabbar是一个系统自带的组件,将pages的列表存储到tabbar的data之中,
根据点击的位置确认switchtab的页面,然后在页面show的时候通过gettabbar获取到tabbar,然后通过
修改内部的选中的index,使其出现高亮的效果。不过在项目中tabbar包含的页面都是一次性加载,第
二次进入页面的时候不会触发onload钩子,某些操作需要写到onshow钩子中。

おすすめ

転載: blog.csdn.net/qq_41383900/article/details/108233511