el-pagination refs

by hsna

HTML

<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.2.2/lib/index.js"></script>
<div id="app">
<p>
current-page: {{ currentPage }} で固定
</p>
<p>
internalCurrentPage変更なし
</p>
<el-pagination ref="paginationTop" small layout="prev, pager, next" :total="50" :current-page.sync="currentPage">
</el-pagination>
<p>
internalCurrentPageも変更
</p>
<el-pagination ref="paginationBottom" small layout="prev, pager, next" :total="50" :current-page.sync="currentPage">
</el-pagination>
</div>

SCSS

@import url("//unpkg.com/element-ui@2.2.2/lib/theme-chalk/index.css");

Babel + JSX

var Main = {
	data () {
  	return {
    	currentPage: 1,
      internalPage: {
      	top: null,
        bottom: null
      }
    }
  },
  mounted () {
  	this.internalPage.top = this.$refs.paginationTop
    this.internalPage.bottom = this.$refs.paginationBottom
  },
  watch: {
  	currentPage () {
    	this.currentPage = 1
      this.internalPage.bottom.internalCurrentPage = this.currentPage
    }
  }
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')