H5W3
当前位置:H5W3 > JavaScript > Vue相关 > 正文

【Vue】iview分页组件的on-change事件无法触发

changePage()函数里面执行了console.log
但是

<Page :total="page.total" :page-size="page.pageSize" :current="page.page" show-total show-elevator show-sizer @on-change="changePage()"></Page>

如果这样写代码,那么报

TypeError: _vm.changePage is not a function
at on-change (eval at ./node_modules/vue-loader/lib/template-compiler/index.js?{"id":"data-v-a4e6edc6","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/components/index/TaskList.vue (0.3529ec41d52ff9a2feda.hot-update.js:14), <anonymous>:39:21)
at VueComponent.invoker (vue.esm.js:2003)
at VueComponent.Vue.$emit (vue.esm.js:2514)
at VueComponent.changePage (iview.js:14756)
at VueComponent.boundFn [as changePage] (vue.esm.js:191)
at VueComponent.next (iview.js:14771)
at boundFn (vue.esm.js:191)
at invoker (vue.esm.js:2003)
at HTMLLIElement.fn._withTask.fn._withTask (vue.esm.js:1801)

如果这样写代码

<Page :total="page.total" :page-size="page.pageSize" :current="page.page" show-total show-elevator show-sizer @on-change="changePage"></Page>

那么什么都不会输出

所以这个是什么情况呢?

回答

<Page :total="page.total" :page-size="page.pageSize" :current="page.page" show-total show-elevator show-sizer @on-change="changePage"></Page>
changePage(val){
    console.log(val)
}

val就是改变的页数

本文地址:H5W3 » 【Vue】iview分页组件的on-change事件无法触发

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址