繁体   English   中英

在React Native中导出方法/功能

[英]Export method/function in react native

export { width as responsiveHeight } from "react-native-responsive-dimensions";

我想导出名称为width responsiveHeight width 正确的方法是什么? 由于这是行不通的。

您的语法相反。 您想获得width responsiveHeight width

尝试这个

export { responsiveHeight as width } from "react-native-responsive-dimensions";

实际上,您在做相反的事情,您正在使用width函数,并为其添加了一个名为sensitiveHeight的别名,因此您需要执行以下操作:

export { responsiveHeight } from "react-native-responsive-dimensions";

就这么简单,以这种方式导出宽度,它应该没有问题。

试试这个。

import React from "react";
import {responsive} from "react-native-responsive-ui";

@responsive
export default class Debug extends React.Component {
    render() {
        const {width, height} = this.props.window;
        console.log(`New window dimensions: ${width}x${height}`);
        return null;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM