由于某些原因,我无法使tailwind rn实际上为我的程序设置样式。当我运行expo start时,即使我在代码中设置了居中排列,项目也没有对齐到中心。
import { StyleSheet, Text, View, Button } from 'react-native';
import {TailwindProvider} from 'tailwind-rn';
import utilities from './tailwind.json';
import {useTailwind} from 'tailwind-rn';
export default function App() {
const tailwind = useTailwind();
return (
<TailwindProvider utilities={utilities}>
<View style={tailwind('flex-1 items-center justify-center')}>
<Text>Hello</Text>
<StatusBar style="auto" />
</View>
</TailwindProvider>
);
}
这是我的package.json文件:
{
"name": "mari-application",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"build:tailwind": "tailwindcss --input input.css --output tailwind.css --no-autoprefixer && tailwind-rn",
"dev:tailwind": "concurrently \"tailwindcss --input input.css --output tailwind.css --no-autoprefixer --watch\" \"tailwind-rn --watch\""
},
"dependencies": {
"expo": "~45.0.0",
"expo-status-bar": "~1.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-web": "0.17.7",
"tailwind-rn": "^4.2.0"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"concurrently": "^7.2.2",
"postcss": "^8.4.14",
"tailwindcss": "^3.1.6"
},
"private": true
}
npm install tailwind-rn
,然后运行npx setup-tailwind-rn
? - Rahman Haroon<Text>
中使用其他类,如text-red-500
,看看是否起作用。 - MagnusEffect