这很奇怪,这是一个到底发生了什么的例子
import { View, Text } from "react-native";
import { StyleSheet } from "react-native";
export default function EditScreenInfo({ path }: { path: string }) {
return (
<>
<View className='mt-12 items-center'>
<Text>Open up the code for this screen:</Text>
</View>
<View className='mt-12'>
<Text className='text-center'>
Change any of the text, save the file, and your app will automatically
update.
</Text>
</View>
</>
);
}
问题是,如果你将
mt-12
中的12更改为任何其他数字,mt将停止工作
和
text-center
也不起作用
import { View, Text } from "react-native";
import { StyleSheet } from "react-native";
export default function EditScreenInfo({ path }: { path: string }) {
return (
<>
<View className='mt-12 items-center'>
<Text>Open up the code for this screen:</Text>
</View>
<View className='mt-10'>
<Text className='text-center'>
Change any of the text, save the file, and your app will automatically
update.
</Text>
</View>
</>
);
}
看到了吗?我变了
<View className='mt-12'>
<Text className='text-center'>
Change any of the text, save the file, and your app will automatically
update.
</Text>
</View>
到
<View className='mt-10'>
<Text className='text-center'>
Change any of the text, save the file, and your app will automatically
update.
</Text>
</View>
className='mt-12'
至 className='mt-10'
它停止工作,无论我输入什么数字,它只适用于 mt-12,为什么?
"nativewind": "^4.1.23",
"tailwindcss": "^3.4.16"
根据文档实施一切
我尝试通过 npx expo start --clear 不带缓存重新启动,但在那之后 mt-10 仍然不适用
事实证明,在 tailwind.config.js 的文档中,没有将样式应用到组件文件夹的路径,这就是问题所在
/** @type {import('tailwindcss').Config} */
module.exports = {
// NOTE: Update this to include the paths to all of your component files.
darkMode: "class",
content: ["./app/**/*.{js,jsx,ts,tsx}", "./components/**/*.{js,jsx,ts,tsx}"],
presets: [require("nativewind/preset")],
theme: {
extend: {},
},
plugins: [],
};
"./components/**/*.{js,jsx,ts,tsx}"
注意