chore: format ref name

This commit is contained in:
chenjiahan 2020-08-26 11:49:35 +08:00
parent b0ea4bc1f6
commit e3a59afb07
3 changed files with 16 additions and 16 deletions

View File

@ -27,8 +27,8 @@ export default createComponent({
}, },
setup(props, { slots }) { setup(props, { slots }) {
const wrapper = ref(null); const wrapperRef = ref(null);
const content = ref(null); const contentRef = ref(null);
const { parent, index } = useParent(COLLAPSE_KEY); const { parent, index } = useParent(COLLAPSE_KEY);
const currentName = computed(() => const currentName = computed(() =>
@ -49,7 +49,7 @@ export default createComponent({
if (!expanded.value) { if (!expanded.value) {
show.value = false; show.value = false;
} else { } else {
wrapper.value.style.height = ''; wrapperRef.value.style.height = '';
} }
}; };
@ -67,18 +67,18 @@ export default createComponent({
const tick = value ? nextTick : raf; const tick = value ? nextTick : raf;
tick(() => { tick(() => {
if (!content.value || !wrapper.value) { if (!contentRef.value || !wrapperRef.value) {
return; return;
} }
const { offsetHeight } = content.value; const { offsetHeight } = contentRef.value;
if (offsetHeight) { if (offsetHeight) {
const contentHeight = `${offsetHeight}px`; const contentHeight = `${offsetHeight}px`;
wrapper.value.style.height = value ? 0 : contentHeight; wrapperRef.value.style.height = value ? 0 : contentHeight;
// use double raf to ensure animation can start // use double raf to ensure animation can start
doubleRaf(() => { doubleRaf(() => {
wrapper.value.style.height = value ? contentHeight : 0; wrapperRef.value.style.height = value ? contentHeight : 0;
}); });
} else { } else {
onTransitionEnd(); onTransitionEnd();
@ -121,12 +121,12 @@ export default createComponent({
if (shouldRender.value) { if (shouldRender.value) {
return ( return (
<div <div
ref={wrapper} ref={wrapperRef}
vShow={show.value} vShow={show.value}
class={bem('wrapper')} class={bem('wrapper')}
onTransitionend={onTransitionEnd} onTransitionend={onTransitionEnd}
> >
<div ref={content} class={bem('content')}> <div ref={contentRef} class={bem('content')}>
{slots.default?.()} {slots.default?.()}
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
import { ref } from 'vue'; import { ref, reactive } from 'vue';
import { deepAssign } from '../utils/deep-assign'; import { deepAssign } from '../utils/deep-assign';
import defaultMessages from './lang/zh-CN'; import defaultMessages from './lang/zh-CN';
@ -6,13 +6,13 @@ type Message = Record<string, any>;
type Messages = Record<string, Message>; type Messages = Record<string, Message>;
const lang = ref('zh-CN'); const lang = ref('zh-CN');
const messages = ref<Messages>({ const messages = reactive<Messages>({
'zh-CN': defaultMessages, 'zh-CN': defaultMessages,
}); });
export default { export default {
messages(): Message { messages(): Message {
return messages.value[lang.value]; return messages[lang.value];
}, },
use(newLang: string, newMessages?: Message) { use(newLang: string, newMessages?: Message) {
@ -21,6 +21,6 @@ export default {
}, },
add(newMessages: Message = {}) { add(newMessages: Message = {}) {
deepAssign(messages.value, newMessages); deepAssign(messages, newMessages);
}, },
}; };

View File

@ -27,12 +27,12 @@ export default createComponent({
emits: ['click-left', 'click-right'], emits: ['click-left', 'click-right'],
setup(props, { emit, slots }) { setup(props, { emit, slots }) {
const navBar = ref(null);
const height = ref(null); const height = ref(null);
const navBarRef = ref(null);
onMounted(() => { onMounted(() => {
if (props.placeholder && props.fixed) { if (props.placeholder && props.fixed) {
height.value = navBar.value.getBoundingClientRect().height; height.value = navBarRef.value.getBoundingClientRect().height;
} }
}); });
@ -69,7 +69,7 @@ export default createComponent({
const { title, fixed, border, zIndex } = props; const { title, fixed, border, zIndex } = props;
return ( return (
<div <div
ref={navBar} ref={navBarRef}
style={{ zIndex }} style={{ zIndex }}
class={[bem({ fixed }), { [BORDER_BOTTOM]: border }]} class={[bem({ fixed }), { [BORDER_BOTTOM]: border }]}
> >