【问题标题】:Increment id for new block新块的增量 id
【发布时间】:2018-06-25 15:44:35
【问题描述】:

请帮忙 1.需要给新元素添加unic id 2.如果添加console.log(...),它将正常工作,否则它总是保持id:3
example
code
onAdd() { if(this.carModel === '' || this.carName === '') return this.id = this.id++; -work

onAdd() { if(this.carModel === '' || this.carName === '') return this.id = this.id++; - 不工作

【问题讨论】:

  • 尝试返回 this.id++;在你的情况下这应该足够了
  • 您能否发布一个简单的代码示例来说明您目前拥有的以及您正在尝试做的事情?这会让其他人更容易帮助你。
  • 我只是编辑,但为什么这取决于“返回”在哪里?

标签: angular increment


【解决方案1】:

我只是删除顶部的“return”,然后在新行中写入 this.id...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-01
    • 1970-01-01
    • 2012-10-09
    • 2012-06-05
    相关资源
    最近更新 更多