删除pages组件的调度代码;修复组件初始化时的旧回调
parent
7784e87511
commit
d3ec859f24
|
@ -3435,15 +3435,13 @@
|
||||||
var componentQueue = []
|
var componentQueue = []
|
||||||
var widgetList = []
|
var widgetList = []
|
||||||
var componentHooks = {
|
var componentHooks = {
|
||||||
construct: function(props, state, next) {
|
construct: noop,
|
||||||
next(props, state)
|
|
||||||
},
|
|
||||||
componentWillMount: noop,
|
componentWillMount: noop,
|
||||||
componentDidMount: noop,
|
componentDidMount: noop,
|
||||||
childComponentDidMount: noop,
|
childComponentDidMount: noop,
|
||||||
componentWillUnmount: noop,
|
componentWillUnmount: noop,
|
||||||
render: function(str) {
|
render: function() {
|
||||||
return str
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,16 +37,13 @@ function calculate({ currPage, maxPageShow, totalPages }) {
|
||||||
}
|
}
|
||||||
// 更新组件
|
// 更新组件
|
||||||
function update(currPage, vm) {
|
function update(currPage, vm) {
|
||||||
const { totalPages, props } = vm
|
const { totalPages, props: { maxPageShow } } = vm
|
||||||
vm.currPage = vm.inputPage = currPage
|
vm.currPage = vm.inputPage = currPage
|
||||||
vm.props.onPageChange.call(null, currPage)
|
vm.props.onPageChange.call(null, currPage)
|
||||||
if (totalPages < 2) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
vm.pageList.clear()
|
vm.pageList.clear()
|
||||||
vm.pageList.pushArray(
|
if (totalPages > 1) {
|
||||||
calculate({ currPage, totalPages, maxPageShow: props.maxPageShow })
|
vm.pageList.pushArray(calculate({ currPage, totalPages, maxPageShow }))
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Anot.component('pages', {
|
export default Anot.component('pages', {
|
||||||
|
@ -84,7 +81,7 @@ export default Anot.component('pages', {
|
||||||
:attr="{href: parseUrl(totalPages)}"
|
:attr="{href: parseUrl(totalPages)}"
|
||||||
:click="setPage(totalPages, $event)">{{props.btns.end}}</a>
|
:click="setPage(totalPages, $event)">{{props.btns.end}}</a>
|
||||||
|
|
||||||
<div class="input-box" :if="!props.simpleMode">
|
<div class="input-box" :if="!props.simpleMode && totalPages > 1">
|
||||||
<span>共 {{totalPages}} 页 {{totalItems}} 条,前往</span>
|
<span>共 {{totalPages}} 页 {{totalItems}} 条,前往</span>
|
||||||
<input type="text" :duplex="inputPage" :keyup="setPage(null, $event)">
|
<input type="text" :duplex="inputPage" :keyup="setPage(null, $event)">
|
||||||
<span>页</span>
|
<span>页</span>
|
||||||
|
@ -115,7 +112,6 @@ export default Anot.component('pages', {
|
||||||
return Math.ceil(this.totalItems / this.pageSize)
|
return Math.ceil(this.totalItems / this.pageSize)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
skip: ['currPage', 'totalItems', 'pageSize'],
|
|
||||||
props: {
|
props: {
|
||||||
url: null,
|
url: null,
|
||||||
btns: {
|
btns: {
|
||||||
|
@ -184,7 +180,6 @@ export default Anot.component('pages', {
|
||||||
update(1, this)
|
update(1, this)
|
||||||
},
|
},
|
||||||
setTotalItems: function(num) {
|
setTotalItems: function(num) {
|
||||||
console.log(this, num)
|
|
||||||
this.totalItems = +num
|
this.totalItems = +num
|
||||||
update(1, this)
|
update(1, this)
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue