导出模块(元素类型预期的字符串无效)



我在索引页中打电话给trafik.js,但它没有运行,我做错了,我不知道为什么...

元素类型无效:预期一个字符串(用于内置组件)或类/函数(对于复合组件),但got:对象。检查dene1的渲染方法。

1- index.android.js

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableHighlight,
  Navigator
} from 'react-native';
import Trafik from './Trafik'

var dene1 = React.createClass({
render : function(){
return  <View style = {[style.container,this.border('red')]} >
{this.header()}
{this.middle()}
{this.footer()}
<Trafik/>
        </View>
}, //render
header:function(){
 return   <View style = {[style.header,this.border('yellow')]}>
 <View style={[style.teklifBtn,this.border('blue')]}>
<Text>
Teklifler
</Text>
 </View>
  <View style={[style.mesajBtn,this.border('blue')]}>
  <Text>
Mesajlar
</Text>
 </View>
         </View>    
    },
middle:function(){
 return   <View style = {[style.middle,this.border('green')]}>
<Text>
middle
</Text>
         </View>    
},
footer:function(){
 return   <View style = {[style.footer,this.border('black')]}>
 <TouchableHighlight style={[style.kaskoBtn,this.border('blue')]}>
<Text>
kasko
</Text>
 </TouchableHighlight>
  <TouchableHighlight  underlayColor='red'  style={[style.trafikBtn,this.border('blue')]}>
  <Text>
trafik
</Text>
 </TouchableHighlight>
  <TouchableHighlight style={[style.yanginBtn,this.border('blue')]}>
<Text>
yangin
</Text>
 </TouchableHighlight>
  <TouchableHighlight style={[style.seyahatBtn,this.border('blue')]}>
  <Text>
seyahat
</Text>
 </TouchableHighlight>
         </View>    
},
border:function(color){
    return {
    borderColor : color,
    borderWidth: 4
    }
},

}) ;//dene1
var style = StyleSheet.create({
container :{
        flex:1,
    },
    header : {
        flex :0.9,
        flexDirection:'row',

},
    middle : {
        flex :3,
        flexDirection:'row',
        justifyContent:'center',
         alignItems: 'center',
    },
    footer:{
        flex :4,
        flexDirection:'column',

    },
        teklifBtn:{
        flex :1,
        justifyContent:'center',
         alignItems: 'center',
         backgroundColor:'red'
    },
        mesajBtn:{
        flex :1,
         justifyContent:'center',
         alignItems: 'center',
    },
        kaskoBtn:{
        flex :1,
         justifyContent:'center',
         alignItems: 'center',

    },
        trafikBtn:{
        flex :1,
         justifyContent:'center',
         alignItems: 'center',
    },
        yanginBtn:{
        flex :1,
         justifyContent:'center',
         alignItems: 'center',
    },
        seyahatBtn:{
        flex :1,
         justifyContent:'center',
         alignItems: 'center',
    },

})
AppRegistry.registerComponent('dene1', () => dene1);

2.trafik.js

'use strict';
import React, { Component } from 'react';
import {
  Text,
  View
} from 'react-native';

var Trafik = React.createClass({
render : function(){
return  
<Text>
trafik sayfası
</Text>
}
}) ;//dene1
module.export = Trafik;

在trafik.js最后一行替换中尝试一下 模块= trafik;和 导出默认trafik;

相关内容

  • 没有找到相关文章

最新更新