vue 转react尝试

发布时间:2020-06-04 20:20:03 作者:terrycai
阅读:463
Vue开发者专用服务器,限时0元免费领! 查看>>

今天学习了一下react,感觉跟vue 语法类似。于是举一反三搜索了一下,发现由个工具,可以提供这样子的服务:

https://tools.w3cub.com/vue-to-react

vue 和 react 的生命周期

created: 'componentWillMount',
mounted: 'componentDidMount',
updated: 'componentDidUpdate',
beforeDestroy: 'componentWillUnmount',
errorCaptured: 'componentDidCatch',
render: 'render'

react 没有 computeds

react 没有 computed, 需要支持 手动 setState

hooks 语法

hooks 下如何还原 setState 类似的操作:

可以使用 useReducer

const [state, setState] = useReducer(
    (state, action) => {
      return {
        ...state,
        ...action
      };
    },{ name: '小熊猫',category: '小熊猫科' })
setState({ name: '金鱼' })

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:
  1. React转Vue
  2. 在react中如何使用vue的状态管理

开发者交流群:

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vue react 转换

上一篇:robot自动化测试环境安装

下一篇:cocoscreator构建的android工程报错

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》
开发者交流群×