RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-267880

epsilon's questions

Martin Hope
epsilon
Asked: 2020-04-23 23:38:47 +0000 UTC

React 中的数组合二为一

  • 0

有一种形式,其中有两个输入,当每个输入发生变化时,组件的状态就会发生变化(recipeName, recipeIngredients)。接下来是一个Добавить创建对象的按钮

let recipe = {
  name: this.state.recipeName,
  ingredients: this.state.recipeIngredients.split(',')
}

并将其添加到食谱数组中

addRecipe(e) {
        if (this.state.recipeName.length > 0 && this.state.recipeIngredients.length > 0) {
            let recipe = {
                name: this.state.recipeName,
                ingredients: this.state.recipeIngredients
            }
            this.setState({
                recipes: this.state.recipes.push(recipe)
            })
            this.handleClose(); //закрытие модального окна, в котором всё происходит
        } else {
            alert('Fill all inputs!')
        } 
    }

试图显示数组的内容

<ul>
  {this.state.recipes.map(item => <li>item.name</li>)}
</ul>

在这个阶段,recipes由于某种原因,数组相等1并显示错误TypeError: this.state.recipes.map is not a function

javascript
  • 1 个回答
  • 10 Views
Martin Hope
epsilon
Asked: 2020-03-06 15:56:22 +0000 UTC

在 Angular 5 中的组件之间传递数据

  • 1

现在,如果有两个组件,并且在第一个组件中有某种方法,假设这个方法接收数据。您需要将此接收到的数据发送到第二个相邻组件。

<child1></child1>
<child2></child2>

怎么做?这样做是否值得?提前致谢

angular5
  • 1 个回答
  • 10 Views
Martin Hope
epsilon
Asked: 2020-12-05 01:30:31 +0000 UTC

如何在反应中改变另一个组件的状态

  • 1

有两个组件

首先

class AddRecipe extends React.Component {
    constructor(props) {
        super(props);
        this.state = {show: this.props.show}
    }
    render() {
        if (this.state.show) {
            return (
                <div className="add-area"></div>
            )
        }
        else 
            return(<nothing />)
    }
}

第二

class Project extends React.Component {
    constructor(props) {
        super(props);
        this.changeShowAddArea = this.changeShowAddArea.bind(this);
        this.state = {showAddArea: false};
    }
    changeShowAddArea() {
        this.setState({
            showAddArea: true
        })

    }
    render() {
        return(
            <div className="container">
                <RecipeArea />
                <Button bsStyle="primary" onClick={this.changeShowAddArea} id="add">
                    Add a recipe
                </Button>
                <AddRecipe show={this.state.showAddArea}/>
            </div>
        );
    }
}

当我点击按钮 this.state.showAddArea 发生变化,但 AddRecipe 没有显示,我该如何解决这个问题?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
epsilon
Asked: 2020-11-18 14:21:29 +0000 UTC

打开模态窗口

  • 1

实际上问题是,当在页面上打开一个模式窗口(从引导程序)时,页面滚动被翻译到最顶部。你怎么能摆脱这个?

模态窗口

<div class="modal fade" id="modalView" tabindex="-1" role="dialog" aria-labelledby="modalView" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document" >
        <div class="modal-content" style="background: linear-gradient(#1A1E21, #1A1E21, #1A1E21);; color: #fff;">
            <div class="modal-header"">
                <h5 class="modal-title" id="modalViewTitle"></h5>
                <button class="close" type="button" data-dismiss="modal" aria-label="Close" >
                    <span aria-hidden="true" style="color: #fff !important;">&times;</span>
                </button>
            </div>
            <div class="modal-body" >
                <div class="container-fluid text-center">
                    <img src="" alt="photo" width="90%" height="auto" id="modalViewImage">
                    <p id="modalViewText" style="margin-top: 20px; font-size: 20px;">

                    </p>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

不管有没有影响,不过我也会贴出来

<html lang="en" style='overflow-x: hidden;'>

模态窗口通过js打开

$(".view").click(function() {
    $("#modalView").modal('show');
}
html
  • 1 个回答
  • 10 Views
Martin Hope
epsilon
Asked: 2020-11-16 00:09:52 +0000 UTC

将图像添加到 PHP 时事通讯

  • 1

有一个表单,其中有两个输入,带有新闻的标题和文本,还有一个提交按钮。直到我想在这条新闻中添加图片之前,添加新闻都没有问题。首先想到的是在数据库中的新闻表中添加另一个字段,名称为需要添加的图片名称,显示新闻时只需添加标签即可<img src='image/полеСназваниемКартинки'>。但是上传图片,一键发送数据到数据库是不行的,如果先单独上传图片,再上传新闻,那怎么把图片链接到新闻呢?我不擅长php,新手。在论坛里翻找答案,我经常发现俄罗斯社区非常消极,他们开始侮辱,他们说,去谷歌阅读文档。我个人没有遇到过这种情况,但我逐渐开始对俄罗斯社区感到失望

php
  • 1 个回答
  • 10 Views
Martin Hope
epsilon
Asked: 2020-10-03 22:18:52 +0000 UTC

在c#中编辑xml文件

  • 3

我在 xml 文件中有一个列表,我通过它并在文本框中显示它,但是如果我需要在 xml 文件中添加/删除元素怎么办?这如何通过代码来完成?

<?xml version="1.0" encoding="utf-8"?>
<root>
  <list>item1</list>
  <list>item2</list>
  <list>item3</list>
</root>

xml文件这样读取

XmlDocument doc = new XmlDocument();
doc.Load("list.xml");
c#
  • 1 个回答
  • 10 Views
Martin Hope
epsilon
Asked: 2020-09-20 11:48:33 +0000 UTC

c#中如何保存数据

  • 3

如何在程序中保存数据?例如,如果我有一个控制台应用程序,我要计算我的预算,每次打开程序时,我都会从我的预算中增加或减少资金。

c#
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5