【问题标题】:update item in array in Vue didn't update it in html but it updates value in cliVue中数组中的更新项目没有在html中更新它,但它在cli中更新了值
【发布时间】:2019-04-27 05:19:45
【问题描述】:

我有一个用 Vue js 编码的项目单个 Web 应用程序我有一个对象数组,当通过为对象索引分配新值来更新任何对象时,该对象数组呈现为 html 中的对象列表,但我看到更新来自剪辑

代码示例this.chatRoomsArray[index] = {name:"ahmed",id:10,read:true};

【问题讨论】:

  • 你能提供一些代码吗?
  • 代码示例 this.chatRoomsArray[index] = {name:"ahmed",id:10,read:true}; stackoverflow.com/users/10038915/jns
  • @mooody 请编辑问题并向其添加代码。如果您具体了解代码 sn-ps 的问题,您更有可能得到好的答案。

标签: javascript html css arrays vue.js


【解决方案1】:

你应该使用 this.$set :

this.$set(this.chatRoomArray,index,{name :Ahmed, id:10,read:true })

【讨论】:

猜你喜欢
  • 2018-09-23
  • 1970-01-01
  • 1970-01-01
  • 2018-04-27
  • 2020-08-27
  • 1970-01-01
  • 1970-01-01
  • 2018-01-20
  • 2014-09-22
相关资源
最近更新 更多