search

Home  >  Q&A  >  body text

ios - 请问一下这句话是什么意思?

React 是通过require引入进来的。如图:

方括号内部的各种元素也是通过require方式引进来的。

那么第一幅图中的语句是什么意思呢?

高洛峰高洛峰2887 days ago352

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 18:00:23

    In ES5, if you use the CommonJS standard, the introduction of the React package is basically done through require. The code is similar to this:

    //ES5
    var React = require("react-native");
    var {
        Image,
        Text,
        PropTypes
    } = React;  //引用不同的React Native组件
    

    In ES6, the import writing method is more standard

    //ES6
    import React, {
        Image, 
        Text,
        PropTypes
    } from 'react-native';
    

    Note that in React Native, import will not work properly until 0.12+.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 18:00:23

    Figure 1 is the writing method of ES6, destructuring assignment, simple usage:
    Array:
    var [a, b, c] = [1, 2, 3];var [a, b, c] = [1, 2, 3];
    对象:
    var { foo, bar } = { foo: "aaa", bar: "bbb" };Object:

    var { foo, bar } = { foo: "aaa", bar: "bbb" };🎜
    var test = { foo: "aaa", bar: "bbb" };
    var { foo, bar } = test;
    console.log(foo) // "aaa"

    reply
    0
  • Cancelreply