我正在尝试使用 MERN 堆栈创建一个项目,但遇到了此错误。我已经添加了 JSON 文件的代理,但仍然没有成功。
错误:
GET http://localhost:5000/posts net::ERR_CONNECTION_REFUSED
Run Code Online (Sandbox Code Playgroud)
我的行动:
export const getPosts = () => async (dispatch) => {
try {
const {data} = await api.fetchPosts();
dispatch({type: 'FETCH_ALL', payload: data});
} catch (error) {
console.log(error.message);
}
// const action = {type: 'FETCH_ALL', payload: []}
// dispatch(action);
}
export const createPost = (post) => async (dispatch) => {
try {
const {data} = await api.createPost(post);
dispatch({type: 'CREATE', payload: data})
} catch (error) {
console.log(error);
}
}
Run Code Online (Sandbox Code Playgroud)
我的路线/帖子:
const router = …Run Code Online (Sandbox Code Playgroud) 我已经在 flutter 中开发了一个移动应用程序几天了,只是为了重用一些代码,我想将一个小部件作为参数传递,这样我就不必重复一堆代码。我尝试了在这里找到的一些解决方案,但没有一个有效。
这是我到目前为止所拥有的:
CarouselItem.dart
class CarouselItem extends StatelessWidget {
CarouselItem({
Key? key,
required this.index, required this.height, required this.width, required this.title, required this.destination,
}) : super(key: key);
final int index;
final double height;
final double width;
final String title;
final RouteOneCallBack destination; //trying to pass the widget
//List of images
List<String> list = [
'https://audioguia.s3.eu-west-3.amazonaws.com/FOTOS/Alqueva/A1-placa+entrada.jpg',
];
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.all(6.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(30.0),
child: GestureDetector(
child: Image.network(
list[index],
fit: …Run Code Online (Sandbox Code Playgroud)