chore: improve exposed api

This commit is contained in:
chenjiahan
2020-08-26 11:14:36 +08:00
parent 762aed3e5d
commit d0848544d4
3 changed files with 39 additions and 30 deletions
+14 -14
View File
@@ -1,4 +1,4 @@
import { ref, computed } from 'vue';
import { ref, computed, getCurrentInstance } from 'vue';
import { createNamespace, addUnit } from '../../utils';
import { unitToPx } from '../../utils/format/unit';
import { setScrollTop } from '../../utils/dom/scroll';
@@ -246,19 +246,19 @@ export default createComponent({
return <div ref={daysRef} />;
};
return (vm) => {
vm.getDate = getDate;
vm.getTitle = getTitle;
vm.getHeight = getHeight;
vm.setVisible = setVisible;
vm.scrollIntoView = scrollIntoView;
// @exposed-api
const vm = getCurrentInstance().proxy;
vm.getDate = getDate;
vm.getTitle = getTitle;
vm.getHeight = getHeight;
vm.setVisible = setVisible;
vm.scrollIntoView = scrollIntoView;
return (
<div class={bem('month')} ref={monthRef} style={monthStyle.value}>
{renderTitle()}
{renderDays()}
</div>
);
};
return () => (
<div class={bem('month')} ref={monthRef} style={monthStyle.value}>
{renderTitle()}
{renderDays()}
</div>
);
},
});