我创建了一个项目,expo-camera
点击按钮打开相机。但是,当我第一次单击该按钮时,仅呈现黑屏,重新打开屏幕并单击同一按钮后,相机 UI 会在屏幕上呈现。
我不知道为什么它首先显示黑屏。该问题仅存在于 android 设备中。
链接到 Expo Snack在 android 设备上试试这个例子。
import React, { useState, useEffect, useContext } from 'react';
import {
SafeAreaView,
View,
Text,
Dimensions,
ImageBackground,
Image,
Alert,
} from 'react-native';
import { Camera } from 'expo-camera';
import { Entypo, Ionicons, FontAwesome } from '@expo/vector-icons';
import { Surface, Button, TextInput } from 'react-native-paper';
const { width, height } = Dimensions.get('window');
let cameraRef;
const PickImage = ({ navigation }) => {
const [hasPermission, setHasPermission] = useState(null); …
Run Code Online (Sandbox Code Playgroud) 在这里,我尝试使用 userId 获取用户创建的地点。这是用户模型和地点模型,在控制器中,我编写了通过 userId 获取地点的逻辑。不幸的是,我在 res.json({}) 方法中发送响应时收到错误“UnhandledPromiseRejectionWarning: TypeError: place.toObject is not a function”。
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const placeSchema = new Schema({
title: { type: String, required: true },
description: { type: String, required: true },
image: { type: String, required: true },
address: { type: String, required: true },
location: {
lat: { type: Number, required: true },
lng: { type: Number, required: true },
},
creator: { type: mongoose.Types.ObjectId, required: true, ref: 'User'} …
Run Code Online (Sandbox Code Playgroud) 我想创建下图所示的这个表。当单击编辑按钮时,它应该更改为文本字段并按下确认按钮,它应该再次转换为 tr td 标签。
这是我的代码。我创建了对象数组,其中包含 id 属性、name 属性和 value 属性。单击编辑按钮时,它应更改为文本字段,单击确认按钮时,文本字段的值应在对象数组中更新。
import React, { useState } from "react";
import style from "./css/Register.module.css";
import { Table, Button, Icon, TextInput } from "react-materialize";
const ManipulateRegister = () => {
const [RegisterData, setRegisterData] = useState([
{
id: 0,
name: "W Register",
value: 0,
isEdit: false,
},
{
id: 1,
name: "Z Register",
value: 0,
isEdit: false,
},
{
id: 2,
name: "B Register",
value: 0,
isEdit: false,
},
{
id: 3,
name: "C Register", …
Run Code Online (Sandbox Code Playgroud) 我正在 React Native 中创建聊天 UI,其中我希望第一部分(显示消息的地方)应该是可滚动的。
应TextInput
位于屏幕底部,键盘应位于其后面。
用户界面类似于 WhatsApp 聊天屏幕。但我无法重新创建该用户界面。
我也尝试KeyboardAvoidingView
过react-native
,但它对我来说不起作用。
import React, { useEffect, useState } from "react";
import {
ScrollView,
View,
Text,
Alert,
Dimensions,
Platform,
KeyboardAvoidingView,
TextInput,
TouchableOpacity,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";
const App = () => {
const [message, setMessage] = useState([]);
return (
<View
style={{
display: "flex",
flex: 1,
justifyContent: "space-evenly",
alignItems: "center",
height: Dimensions.get("window").height,
width: Dimensions.get("window").width,
}}
>
<View
style={{
height: Dimensions.get("window").height * 0.8, …
Run Code Online (Sandbox Code Playgroud) expo ×2
javascript ×2
react-native ×2
reactjs ×2
arrays ×1
database ×1
expo-camera ×1
mongodb ×1
mongoose ×1
node.js ×1
textinput ×1