chore: prettier all ts code

This commit is contained in:
陈嘉涵
2020-01-19 15:27:28 +08:00
parent 04c49b645a
commit 207e80f396
19 changed files with 124 additions and 68 deletions
+4 -1
View File
@@ -20,7 +20,10 @@ export const ClickOutsideMixin = (config: ClickOutsideMixinConfig) =>
data() {
const clickOutsideHandler = (event: Event) => {
if (this.closeOnClickOutside && !this.$el.contains(event.target as Node)) {
if (
this.closeOnClickOutside &&
!this.$el.contains(event.target as Node)
) {
(this as any)[config.method]();
}
};
+2 -2
View File
@@ -17,7 +17,7 @@ function getElement(selector: string | GetContainer): Element | null {
export function PortalMixin({ ref, afterPortal }: PortalMixinOptions) {
return Vue.extend({
props: {
getContainer: [String, Function] as (PropType<string | GetContainer>),
getContainer: [String, Function] as PropType<string | GetContainer>,
},
watch: {
@@ -33,7 +33,7 @@ export function PortalMixin({ ref, afterPortal }: PortalMixinOptions) {
methods: {
portal() {
const { getContainer } = this;
const el = ref ? this.$refs[ref] as HTMLElement : this.$el;
const el = ref ? (this.$refs[ref] as HTMLElement) : this.$el;
let container;
if (getContainer) {
+10 -3
View File
@@ -25,7 +25,10 @@ type ChildrenMixinThis = {
disableBindRelation?: boolean;
};
export function ChildrenMixin(parent: string, options: ChildrenMixinOptions = {}) {
export function ChildrenMixin(
parent: string,
options: ChildrenMixinOptions = {}
) {
const indexKey = options.indexKey || 'index';
return Vue.extend({
@@ -56,7 +59,9 @@ export function ChildrenMixin(parent: string, options: ChildrenMixinOptions = {}
beforeDestroy() {
if (this.parent) {
this.parent.children = this.parent.children.filter((item: any) => item !== this);
this.parent.children = this.parent.children.filter(
(item: any) => item !== this
);
}
},
@@ -68,7 +73,9 @@ export function ChildrenMixin(parent: string, options: ChildrenMixinOptions = {}
const children = [...this.parent.children, this];
const vnodes = flattenVNodes(this.parent.slots());
children.sort((a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode));
children.sort(
(a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode)
);
this.parent.children = children;
},
+2 -1
View File
@@ -58,7 +58,8 @@ export const TouchMixin = Vue.extend({
// avoid Vue 2.6 event bubble issues by manually binding events
// https://github.com/youzan/vant/issues/3015
bindTouchEvent(el: HTMLElement) {
const { onTouchStart, onTouchMove, onTouchEnd } = (this as any);
const { onTouchStart, onTouchMove, onTouchEnd } = this as any;
on(el, 'touchstart', onTouchStart);
on(el, 'touchmove', onTouchMove);