mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-10 00:12:27 +08:00
新增:Form组件支持响应式配置,路由支持外部地址(内联)
This commit is contained in:
72
src/views/iframe/index.vue
Normal file
72
src/views/iframe/index.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<n-spin :show="loading">
|
||||
<div class="frame">
|
||||
<iframe :src="frameSrc" class="frame-iframe" scrolling="no" ref="frameRef"></iframe>
|
||||
</div>
|
||||
</n-spin>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, unref, onMounted, nextTick } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'IFrame',
|
||||
setup() {
|
||||
const currentRoute = useRoute();
|
||||
const loading = ref(false);
|
||||
const frameRef = ref<HTMLFrameElement | null>(null);
|
||||
const frameSrc = ref<string>('');
|
||||
|
||||
if (unref(currentRoute.meta)?.frameSrc) {
|
||||
frameSrc.value = unref(currentRoute.meta)?.frameSrc as string;
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
function init() {
|
||||
nextTick(() => {
|
||||
const iframe = unref(frameRef);
|
||||
if (!iframe) return;
|
||||
const _frame = iframe as any;
|
||||
if (_frame.attachEvent) {
|
||||
_frame.attachEvent('onload', () => {
|
||||
hideLoading();
|
||||
});
|
||||
} else {
|
||||
iframe.onload = () => {
|
||||
hideLoading();
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loading.value = true;
|
||||
init();
|
||||
});
|
||||
|
||||
return {
|
||||
loading,
|
||||
frameRef,
|
||||
frameSrc,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.frame {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
|
||||
&-iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
border: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user