Skip to content

Commit

Permalink
fix: 修复 popup live demo 问题 (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
honkinglin authored May 7, 2022
1 parent fb0effb commit c4931bd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions site/src/components/base-usage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ onMounted(() => {
usageRef.value.addEventListener('PanelChange', onPanelChange);
});
watchEffect(() => {
usageRef.value.configList = props.configList.filter((config) => config.name !== 'visible');
});
onBeforeUnmount(() => {
usageRef.value.removeEventListener('ConfigChange', onConfigChange);
usageRef.value.removeEventListener('PanelChange', onPanelChange);
Expand All @@ -67,16 +63,23 @@ function onPanelChange(e) {
const defaultProps = ref(
props.configList.reduce((prev, curr) => {
if (curr.name === 'visible') return prev;
if (curr.defaultValue !== undefined) Object.assign(prev, { [curr.name]: curr.defaultValue });
return prev;
}, {}),
);
watchEffect(() => {
usageRef.value.configList = props.configList.filter((config) => config.name !== 'visible');
});
const usageCode = computed(() => {
const propsStrs = Object.keys(changedProps.value)
.map((name) => `${stringifyProp(name, changedProps.value[name])}`)
.filter(Boolean);
const tureCode = props.code.replace(/\s*v-bind="configProps"/g, () => propsStrs.length ? `\n ${propsStrs.join('\n ')}` : '');
const tureCode = props.code.replace(/\s*v-bind="configProps"/g, () =>
propsStrs.length ? `\n ${propsStrs.join('\n ')}` : '',
);
usageRef.value.code = tureCode;
return tureCode;
});
Expand Down

0 comments on commit c4931bd

Please sign in to comment.