下一個項目是geli? tiriyorum。burada er mobile cihaz ise Bir component render et MEK istiyorum。ama bu is mobile device de erini jsx I erisinde kullan rsam a daki hatalaral yorum。
import useTranslation from "next-translate/useTranslation";
import isMobile from "ismobilejs";
import DefaultLayout from "../../components/core/Layouts/Default";
import { MouseIcon, ScrollDownWrapper, ScrollText, SearchBoxWrapper, SliderWrapper, Wrapper } from "./style";
import MainSlider from "../../components/common/MainSlider";
import SearchBox from "../../components/common/SearchBox";
const HomeScreen = () => {
const { t } = useTranslation("home");
const isMobileDevice = isMobile()?.any;
return (
<DefaultLayout>
<Wrapper>
<SearchBoxWrapper>
<SearchBox />
{isMobileDevice && (
<ScrollDownWrapper>
<MouseIcon />
<ScrollText>{t("scrollDown")}</ScrollText>
</ScrollDownWrapper>
)}
</SearchBoxWrapper>
<SliderWrapper>
<MainSlider />
</SliderWrapper>
</Wrapper>
</DefaultLayout>
);
};
export default HomeScreen;
我想在客戶端使用& quot使用客戶端& quot因為isMobijeJs需要window對象但是不行。
你能幫我嗎?
可以使用react-device-detect包。這也是相當容易使用,并有很大的選擇,如spesific查看元素,解決您的問題。我已經(jīng)在Next 13.2上測試過了,可以確認它是有效的。