1. 程式人生 > >輸出和引入js檔案 module.exports

輸出和引入js檔案 module.exports

需要輸出的類

import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
} from 'react-native';

var Dimensions = require('Dimensions');
//獲取螢幕寬度
var screenWidth = Dimensions.get('window').width;

export default class loginView extends Component {
    render() {
        return
( <View> <Text>輸出</Text> </View> ); } } //輸出一個類 module.exports = loginView;

接收檔案的js檔案


import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,

} from 'react-native'
; //引入外部js注意首字母必須大寫 var LoginView = require('./loginModule/iOS/loginView'); export default class B2B extends Component { render() { return ( <LoginView/> ); } } AppRegistry.registerComponent('B2B', () => B2B);