iview / iview/iview-admin

[Vue warn]: Error in callback for watcher "endVal": "TypeError: this.demo.update is not a function"

Open
#764 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Vue
Stars
16.3k
Forks
4.7k
PR merge metrics
No merged PRs in 30d

Description

求助 求助

created: function() {
    let that = this;
    util.ajax
      .get("/users?count=true")
      .then(data => {
          that.count.createUser = 100;
      })
      .catch(function(e) {
        that.$Message.error(e.error);
      });
    //that.count.createUser = 100;
  },

注释掉的代码没问题,then回调函数中调用 出现以下问题

vue.esm.js:578 [Vue warn]: Error in callback for watcher "endVal": "TypeError: this.demo.update is not a function"

found in

---> <CountUp> at src/views/home/components/countUp.vue
       <Row>
         <ICol>
           <Card>
             <InforCard> at src/views/home/components/inforCard.vue
               <ICol>
                 <Row>
                   <ICol>
                     <Row>
                       <Home> at src/views/home/home.vue
                         <Main> at src/views/Main.vue
                           <App> at src/app.vue
                             <Root>
warn @ vue.esm.js:578
logError @ vue.esm.js:1713
globalHandleError @ vue.esm.js:1708
handleError @ vue.esm.js:1697
run @ vue.esm.js:3208
flushSchedulerQueue @ vue.esm.js:2954
(anonymous) @ vue.esm.js:1813
flushCallbacks @ vue.esm.js:1734
Promise.then (async)
microTimerFunc @ vue.esm.js:1782
nextTick @ vue.esm.js:1826
queueWatcher @ vue.esm.js:3041
update @ vue.esm.js:3182
notify @ vue.esm.js:684
reactiveSetter @ vue.esm.js:1009
(anonymous) @ home.vue:239
Promise.then (async)
created @ home.vue:238
callHook @ vue.esm.js:2895
Vue._init @ vue.esm.js:4560
Override.Vue._init @ vue-i18n.common.js:110
VueComponent @ vue.esm.js:4728
createComponentInstanceForVnode @ vue.esm.js:4242
init @ vue.esm.js:4059
createComponent @ vue.esm.js:5512
createElm @ vue.esm.js:5460
patch @ vue.esm.js:5995
Vue._update @ vue.esm.js:2637
updateComponent @ vue.esm.js:2765
get @ vue.esm.js:3115
Watcher @ vue.esm.js:3104
mountComponent @ vue.esm.js:2772
1.Vue$3.$mount @ vue.esm.js:8429
1.Vue$3.$mount @ vue.esm.js:10790
init @ vue.esm.js:4065
createComponent @ vue.esm.js:5512
createElm @ vue.esm.js:5460
createChildren @ vue.esm.js:5586
createElm @ vue.esm.js:5488
createChildren @ vue.esm.js:5586
createElm @ vue.esm.js:5488
createChildren @ vue.esm.js:5586
createElm @ vue.esm.js:5488
patch @ vue.esm.js:5995
Vue._update @ vue.esm.js:2637
updateComponent @ vue.esm.js:2765
get @ vue.esm.js:3115
Watcher @ vue.esm.js:3104
mountComponent @ vue.esm.js:2772
1.Vue$3.$mount @ vue.esm.js:8429
1.Vue$3.$mount @ vue.esm.js:10790
init @ vue.esm.js:4065
createComponent @ vue.esm.js:5512
createElm @ vue.esm.js:5460
updateChildren @ vue.esm.js:5749
patchVnode @ vue.esm.js:5840
patch @ vue.esm.js:6000
Vue._update @ vue.esm.js:2647
updateComponent @ vue.esm.js:2765
get @ vue.esm.js:3115
run @ vue.esm.js:3192
flushSchedulerQueue @ vue.esm.js:2954
(anonymous) @ vue.esm.js:1813
flushCallbacks @ vue.esm.js:1734
Promise.then (async)
microTimerFunc @ vue.esm.js:1782
nextTick @ vue.esm.js:1826
queueWatcher @ vue.esm.js:3041
update @ vue.esm.js:3182
notify @ vue.esm.js:684
reactiveSetter @ vue.esm.js:1009
(anonymous) @ vue-router.esm.js:2508
(anonymous) @ vue-router.esm.js:2507
updateRoute @ vue-router.esm.js:1997
(anonymous) @ vue-router.esm.js:1875
(anonymous) @ vue-router.esm.js:1984
step @ vue-router.esm.js:1714
step @ vue-router.esm.js:1721
step @ vue-router.esm.js:1721
runQueue @ vue-router.esm.js:1725
(anonymous) @ vue-router.esm.js:1979
step @ vue-router.esm.js:1714
(anonymous) @ vue-router.esm.js:1718
(anonymous) @ vue-router.esm.js:1964
(anonymous) @ vue-router.esm.js:1757
(anonymous) @ vue-router.esm.js:1833
Promise.then (async)
(anonymous) @ vue-router.esm.js:1780
(anonymous) @ vue-router.esm.js:1801
(anonymous) @ vue-router.esm.js:1801
flatMapComponents @ vue-router.esm.js:1800
(anonymous) @ vue-router.esm.js:1736
iterator @ vue-router.esm.js:1943
step @ vue-router.esm.js:1717
step @ vue-router.esm.js:1721
step @ vue-router.esm.js:1721
(anonymous) @ vue-router.esm.js:1718
(anonymous) @ vue-router.esm.js:1964
util.toDefaultPage @ util.js:279
(anonymous) @ index.js:50
iterator @ vue-router.esm.js:1943
step @ vue-router.esm.js:1717
runQueue @ vue-router.esm.js:1725
confirmTransition @ vue-router.esm.js:1972
transitionTo @ vue-router.esm.js:1874
init @ vue-router.esm.js:2499
beforeCreate @ vue-router.esm.js:540
callHook @ vue.esm.js:2895
Vue._init @ vue.esm.js:4556
Override.Vue._init @ vue-i18n.common.js:110
Vue$3 @ vue.esm.js:4659
(anonymous) @ main.js:20
__webpack_require__ @ bootstrap ce8f4417b4184f50c576:712
fn @ bootstrap ce8f4417b4184f50c576:117
(anonymous) @ index.js:1
__webpack_require__ @ bootstrap ce8f4417b4184f50c576:712
webpackJsonpCallback @ bootstrap ce8f4417b4184f50c576:25
(anonymous) @ main.js:1
vue.esm.js:1717 TypeError: this.demo.update is not a function
    at VueComponent.endVal (countUp.vue:103)
    at Watcher.run (vue.esm.js:3206)
    at flushSchedulerQueue (vue.esm.js:2954)
    at Array.<anonymous> (vue.esm.js:1813)
    at flushCallbacks (vue.esm.js:1734)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/views/home/components/countUp.vue, especially the endVal watcher named in the stack trace, then compare it with the created callback in home.vue. Reproduce the update triggered by the asynchronous request and trace the demo value. Done means the callback no longer raises the reported TypeError and the count component updates correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.