创建一个mixin的方法 test.js
export default { data: function () { return { pagination: { items: [], total: 0, per_page: 10, from: 1, to: 0, current_page: 1, }, search: {}, } }, mounted() { this.fetchItems(); }, updated() { }, methods: { handleSizeChange(val) { this.pagination.per_page = val; this.fetchItems(); }, handleCurrentChange(val) { this.pagination.current_page = val; this.fetchItems(); }, fetchItems() { console.log(this.pagination.current_page) console.log("fetch-items") }, } };
在content.vue组件里面应用
import listMixin from './test'; export default { components: { }, mixins: [listMixin],