[英]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.