From 8d2d659d6f0211945d5ab6c1eacbbdcc8bcb8f6a Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sun, 7 Jun 2020 09:24:44 +0800 Subject: [PATCH] fix: function default value --- components/_util/vue-types/utils.js | 4 +++- components/affix/index.jsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/_util/vue-types/utils.js b/components/_util/vue-types/utils.js index b56acec0c..d1e556d91 100644 --- a/components/_util/vue-types/utils.js +++ b/components/_util/vue-types/utils.js @@ -81,8 +81,10 @@ export const withDefault = function(type) { warn(`${this._vueTypes_name} - invalid default value: "${def}"`, def); return this; } + + // isFunction(def) 关注 https://github.com/vuejs/vue-next/pull/1291 合并发版本后可删除 this.default = - isArray(def) || isPlainObject(def) + isArray(def) || isPlainObject(def) || isFunction(def) ? function() { return def; } diff --git a/components/affix/index.jsx b/components/affix/index.jsx index 2cb4519b7..afb80a820 100644 --- a/components/affix/index.jsx +++ b/components/affix/index.jsx @@ -31,7 +31,7 @@ const AffixProps = { /** 固定状态改变时触发的回调函数 */ // onChange?: (affixed?: boolean) => void; /** 设置 Affix 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 */ - target: PropTypes.func.def(() => getDefaultTarget), + target: PropTypes.func.def(getDefaultTarget), prefixCls: PropTypes.string, }; const AffixStatus = {