我是React Native的新手,我想在我的React Native应用程序中实现一个浮动按钮,就像下面这样:https://bit.dev/khaledebdelli/components/fancy-floaty-button
我尝试使用npm从终端导入按钮的包,但它显示该文件不存在,因此我将提供的scss文件保存在我的项目目录中。
为了在React Native中使用https://github.com/kristerkari/react-native-sass-transformer文件,我严格按照这个链接中的说明进行操作。
然而,浮动按钮没有出现在我的应用程序中。下面是我在代码中尝试做的事情:
BackButton.js内部:
import 'react-native-gesture-handler';
import * as React from 'react';
import { TouchableOpacity, Text } from 'react-native';
import { useNavigation } from '@react-navigation/native';
{/* CSS file imported in below line of code */}
import styles from './styling/floatButton.scss'
export default function BackButton(props) {
const navigation = useNavigation();
console.log(props.title)
return (
<TouchableOpacity
style={styles.btn}
onPress={() => navigation.navigate(props.to, props.toTransfer)}
>
<Text>
{props.title}
</Text>
</TouchableOpacity>
);
}在hash-tables.js中,我导入了BackButton.js并呈现了BackButton组件:
import 'react-native-gesture-handler';
import * as React from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
import BackButton from '../Components/BackButton';
{*/Below line of code is inside the render function of a class component/*}
<BackButton title='Previous' to='Topics' />这是我在我的应用程序中看到的,而不是浮动按钮:

如果有人能指出我可能出错的地方,我将不胜感激:)
发布于 2020-06-22 10:02:57
我猜你没有正确安装sass,我通常会这样做:"npm install node-sass“在前端,每次都能正常工作:)
https://stackoverflow.com/questions/62506379
复制相似问题