V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
minuux
V2EX  ›  React

react-native 例子中的这个语法叫什么?

  •  
  •   minuux · 2015-06-04 16:07:47 +08:00 · 3432 次点击
    这是一个创建于 3247 天前的主题,其中的信息可能已经有所发展或是发生改变。

    链接:
    https://github.com/facebook/react-native/blob/master/Examples/2048/GameBoard.js

    代码第35行
    ···
    var Tile = function (value?: number, row?: number, column?: number) {

    };
    ···
    value?: number, row?: number, column?: number这个是个什么语法?

    3 条回复    2015-06-05 18:22:19 +08:00
    zythum
        1
    zythum  
       2015-06-04 17:28:14 +08:00
    用 babel 转换为 var Tile = function Tile(value, row, column) {};

    所以估计是某个es7的冷门规范。估计是规定类型什么(类似typescript),但是具体规范在哪没找到....
    leofml
        2
    leofml  
       2015-06-04 18:49:42 +08:00   ❤️ 2
    facebook 出的 http://flowtype.org/

    Flow is a static type checker, designed to find type errors in JavaScript programs
    amphineko
        3
    amphineko  
       2015-06-05 18:22:19 +08:00 via iPhone
    condition ? value-true : value-false

    就是 ? 运算符吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5141 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:31 · PVG 17:31 · LAX 02:31 · JFK 05:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.