2017-10-16 39 views
0

我正嘗試使用react-native-drawer-menu模塊創建滑塊菜單。安裝模塊後。得到一個錯誤無法找到變量樣式。這是從示例複製的代碼:反應本機抽屜菜單:無法找到變量樣式

import React from 'react'; 
import { StyleSheet, Text, View } from 'react-native'; 
import { Provider } from 'react-redux' 
import'../I18n/I18n.js'; 
import RootContainer from './RootContainer' 
import createStore from '../Redux' 
import Drawer from 'react-native-drawer-menu'; 
import {Easing} from 'react-native'; // Customize easing function (Optional) 

// create store 
const store = createStore() 

export default class App extends React.Component { 
    render() { 
    // prepare your drawer content 
    var drawerContent = (<View style={styles.drawerContent}> 
    <View style={styles.leftTop}/> 
    <View style={styles.leftBottom}> 
     <View><Text>Drawer Content</Text></View> 
    </View> 
    </View>); 
    var customStyles = { 
    drawer: { 
     shadowColor: '#000', 
     shadowOpacity: 0.4, 
     shadowRadius: 10 
    }, 
    mask: {}, // style of mask if it is enabled 
    main: {} // style of main board 
    }; 
    return (
    <Drawer 
     style={styles.container} 
     drawerWidth={300} 
     drawerContent={drawerContent} 
     type={Drawer.types.Overlay} 
     customStyles={{drawer: styles.drawer}} 
     drawerPosition={Drawer.positions.Right} 
     onDrawerOpen={() => {console.log('Drawer is opened');}} 
     onDrawerClose={() => {console.log('Drawer is closed')}} 
     easingFunc={Easing.ease} 
    > 
     <View style={styles.content}> 
     <Text>{Object.values(Drawer.positions).join(' ')}</Text> 
     <Text>{Object.values(Drawer.types).join(' ')}</Text> 
     </View> 
    </Drawer> 
); 
} 
} 

如果我從代碼中刪除該變量,那麼幻燈片菜單的工作,但看起來非常糟糕。

enter image description here

你認爲我應該對我自己創建菜單的風格或者我應該從什麼地方進口的?如果我必須創建它,我怎麼知道它需要哪些參數?或者這是一個正常的看法?

回答

1

看起來像你必須自己添加樣式才能看起來完全按照你的想法來抽取內容。爲了實現它,你必須創建Stylesheet

您可以使用this解答,以獲得更多信息關於陣營原生樣式表屬性(這幾乎是類似CSS)

也可能從抽屜式回購本例中是helpful

乾杯。