mpvue icon indicating copy to clipboard operation
mpvue copied to clipboard

使用$set添加新属性可以更新视图 但使用$delete删除属性不能更新视图

Open stalkercn opened this issue 5 years ago • 3 comments
trafficstars

[扼要问题描述]

mpvue 版本号:

[[email protected]]

最小化复现代码:

// 示例代码:
<template>
    <h1 @click="test">{{x.y ? x.y : 'undefined'}}</h1>
</template>
export default {
  data () {
    return {
      i: 0,
      x: {}
    }
  },
  methods: {
    test () {
      if (this.x.y) {
        this.$delete(this.x, 'y')
      } else {
        this.$set(this.x, 'y', ++this.i)
      }
    }
  }
}

观察到的表现:

同样的代码在vue页面中可以正常响应,而在mpvue中却只能响应$set方法。

stalkercn avatar Sep 03 '20 06:09 stalkercn

项目开始以后我才知道mpvue已经好几年没有人维护了 然而现在骑虎难下没法从头开始 希望大家帮忙想想办法 感谢

stalkercn avatar Sep 03 '20 06:09 stalkercn

你可以使用计算属性来控制视图渲染

Ljy0826 avatar Sep 14 '20 02:09 Ljy0826

你可以换成uniapp

geekchenzx avatar Dec 10 '20 02:12 geekchenzx