refactor(NumberKeyboard): remove portal mixin

This commit is contained in:
chenjiahan 2020-08-21 11:05:40 +08:00
parent 54a8608078
commit a4b481c5cc

View File

@ -1,7 +1,6 @@
import { Transition } from 'vue'; import { Teleport, Transition } from 'vue';
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { stopPropagation } from '../utils/dom/event'; import { stopPropagation } from '../utils/dom/event';
import { PortalMixin } from '../mixins/portal';
import { BindEventMixin } from '../mixins/bind-event'; import { BindEventMixin } from '../mixins/bind-event';
import Key from './Key'; import Key from './Key';
@ -9,7 +8,6 @@ const [createComponent, bem] = createNamespace('number-keyboard');
export default createComponent({ export default createComponent({
mixins: [ mixins: [
PortalMixin(),
BindEventMixin(function (bind) { BindEventMixin(function (bind) {
if (this.hideOnClickOutside) { if (this.hideOnClickOutside) {
bind(document.body, 'touchstart', this.onBlur); bind(document.body, 'touchstart', this.onBlur);
@ -21,6 +19,7 @@ export default createComponent({
show: Boolean, show: Boolean,
title: String, title: String,
zIndex: [Number, String], zIndex: [Number, String],
teleport: [String, Object],
closeButtonText: String, closeButtonText: String,
deleteButtonText: String, deleteButtonText: String,
closeButtonLoading: Boolean, closeButtonLoading: Boolean,
@ -238,8 +237,7 @@ export default createComponent({
render() { render() {
const Title = this.genTitle(); const Title = this.genTitle();
const Content = (
return (
<Transition name={this.transition ? 'van-slide-up' : ''}> <Transition name={this.transition ? 'van-slide-up' : ''}>
<div <div
vShow={this.show} vShow={this.show}
@ -257,5 +255,11 @@ export default createComponent({
</div> </div>
</Transition> </Transition>
); );
if (this.teleport) {
return <Teleport to={this.teleport}>{Content}</Teleport>;
}
return Content;
}, },
}); });