diff --git a/__test__/components/iframe-loading.spec.ts b/__test__/components/iframe-loading.spec.ts new file mode 100644 index 00000000..149b0802 --- /dev/null +++ b/__test__/components/iframe-loading.spec.ts @@ -0,0 +1,18 @@ +import { RIframe } from '@/components/RIframe' +import { mount } from '@vue/test-utils' + +describe('RIframe loading strategy', () => { + it.each([ + [true, 'lazy'], + [false, 'eager'], + ['eager', 'eager'], + ] as const)('sets loading=%s to %s', (lazy, expected) => { + const wrapper = mount(RIframe, { props: { lazy, src: '/embed.html' } }) + + try { + expect(wrapper.get('iframe').attributes('loading')).toBe(expected) + } finally { + wrapper.unmount() + } + }) +}) diff --git a/public/examples/embed.html b/public/examples/embed.html new file mode 100644 index 00000000..a46628cd --- /dev/null +++ b/public/examples/embed.html @@ -0,0 +1,24 @@ + + + + +
支持配置化请求数据
-- 支持包裹一个拥有 promise 状态的异步函数,可以用来包裹一个 axios - 请求返回值方法 -
+ return { value, ticket: ticket.id } + }, + { + manual: true, + ...(kind === 'throttle' + ? { throttleWait: 1000 } + : { debounceWait: 1000 }), + }, + ) + + return { kind, input, sent, inputId, query } + }) + + return () => ( +{JSON.stringify(manual.data.value.ticket, null, 2)}
+ ) : (
+ t('request.waiting')
+ )}
+
+ {query.data.value.value} · {query.data.value.ticket}
+
+ ) : (
+ t('request.waiting')
+ )}
+ {text.value}
+ ) : (
+ t('empty')
+ )}
+ {selectedKey.value}
+
+ {current.value === null
+ ? t('cache.missing')
+ : JSON.stringify(current.value)}
+
+ {route.path}
+ 我执行了{this.throttleBtnClickCount}次
-该方法 3s 内仅会执行一次
-我执行了{this.debounceBtnClickCount}次
-该方法将延迟 3s 执行
-- 该指令会强制禁用(通过 css 层面)禁用元素交互。但是 naive ui - 组件提供了完整的 disabled - 属性,所以在组件库有禁用需求时,直接调用组件库 disabled - 属性即可。但是值得注意的是,该指令优先级最高,会覆盖组件 - disabled 属性。 -
-我是可以被禁用的文本内容
-+ 我是可以被禁用的文本内容 +
+{output.value}
+ {submission.value ?? t('empty')}
+ 我可以被拖拽
-我可以被拖拽
-
+ {allocation.value.length
+ ? allocation.value.join(' + ')
+ : t('empty')}
+
+ {text.value || t('empty')}
+ {pkg}
+ {t('about.noMatch')}
+ )} +{JSON.stringify(route.query, null, 2)}
+ {this.$t('showcase.scrollCard', { index: index + 1 })}
+