import { VantComponent } from '../components/vant-ui/common/component' export function VueLikePage (filters, options) { if (typeof filters === 'function') { filters = [filters] } else if (!Array.isArray(filters)) { options = filters filters = [] } if (filters.length > 0) { filters.forEach(filter => options = filter(options)) } options.mixins = options.mixins || [] return VantComponent(options) } /** * 给页面加上生命周期钩子函数 * @param {Object} options 页面选项 * @param {String} method 生命周期key * @param {Function} fn 钩子函数 */ function hookPageLifeTimeMethod (options, method, fn) { let _method if (options[method]) { _method = options[method] } else if (options.methods && options.methods[method]) { _method = options.methods[method] } if (!options.methods) { options.methods = {} } options[method] = options.methods[method] = function (args) { if (fn.call(this, args) === false) { return } if (typeof _method === 'function') { _method.call(this, args) } } return options }