Giter Club home page Giter Club logo

Comments (11)

wuhy avatar wuhy commented on May 14, 2024

@githublyp 可以具体描述下问题是什么吗?然后你可以跟另外你提的问题,一并再看下,不知道那个问题跟你这个问题是否有一定关联性

from okam.

githublyp avatar githublyp commented on May 14, 2024

watch调用两次
watch: {
userInfo: {
handler() {
// 当用户登录完后请求业务逻辑
this.userInfo.uid && this.getUserInfo()
},
deep: true
}
},

from okam.

wuhy avatar wuhy commented on May 14, 2024

@githublyp 没太懂,你这里描述跟标题描述 computed 和 watch 使用冲突有什么直接关系吗?可以具体点描述下你的现象和问题吗?还有 watch 调用两次,具体是做了什么事情触发了两次了?

from okam.

githublyp avatar githublyp commented on May 14, 2024

computed 和 watch 使用冲突,这个是由于computed未重新计算引起的,已经好了;
就是我在watch内:
image

from okam.

wuhy avatar wuhy commented on May 14, 2024

@githublyp userInfo 什么时候设置的,具体怎么设置修改的?是你在外部发起异步请求,更新 store userInfo,然后 watch 这里 handler 触发了两次?然后还有个问题,为啥watch handler 里要手动触发生命周期钩子,这个钩子方法是不应该开发者自己去触发调用的

from okam.

githublyp avatar githublyp commented on May 14, 2024

userInfo 在外部发起异步请求,更新 store userInfo,然后 watch 这里 handler 触发了两次;

from okam.

wuhy avatar wuhy commented on May 14, 2024

userInfo 在外部发起异步请求,更新 store userInfo,然后 watch 这里 handler 触发了两次;

我这边看下能不能复现你的问题

from okam.

wuhy avatar wuhy commented on May 14, 2024

@githublyp 我这边还是不能复现你说的问题,如果方便的话,可以给下能复现你这个问题的代码示例,谢谢~

from okam.

githublyp avatar githublyp commented on May 14, 2024

这是reducer:
image
异步更新了:
SET_STATE_STATUS
SET_STATE_USERINFO

不知道是不是redux的问题

from okam.

wuhy avatar wuhy commented on May 14, 2024

这是reducer:
image
异步更新了:
SET_STATE_STATUS
SET_STATE_USERINFO

不知道是不是redux的问题

大概知道什么问题了,目前实现机制是只要 store 有变化会把所有依赖的 computed props 都重新触发一次计算,导致你这边触发了两次,我这边看下做下优化吧。

from okam.

wuhy avatar wuhy commented on May 14, 2024

@githublyp 你可以更新到最新 0.4.0-beta.3 看下这里问题,这里做了下优化,具体修改逻辑可以看关联的 commit 记录,我先把这个 issue 关了,有问题再 open~

from okam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.