export { width as responsiveHeight } from "react-native-responsive-dimensions";
我想导出名为responsiveHeight
的{{1}}。这样做的正确方法是什么?因为这不起作用。
答案 0 :(得分:3)
您的语法相反。您希望responsiveHeight
为width
。
试试这个
export { responsiveHeight as width } from "react-native-responsive-dimensions";
答案 1 :(得分:2)
你实际上正好相反,你正在使用你的宽度函数并添加一个名为responsiveHeight的别名,所以你需要这样做:
export { responsiveHeight } from "react-native-responsive-dimensions";
就像那样简单,以这种方式导出宽度,它应该没有问题。
答案 2 :(得分:0)
试试这个。
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;
}
}