Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stalkercn opened this issue Sep 3, 2020 · 3 comments

Comments

@stalkercn
Copy link

[扼要问题描述]

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
Copy link
Author

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

@Ljy0826
Copy link

Ljy0826 commented Sep 14, 2020

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

@geekchenzx
Copy link

你可以换成uniapp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants