feat:iframe组件
This commit is contained in:
parent
cfde330ac0
commit
5e00d9ce21
39
main/src/components/custom-iframe/index.vue
Normal file
39
main/src/components/custom-iframe/index.vue
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<iframe v-if="state.url" :src="state.url" frameborder="0" width="100%" height="100%" @load="onLoad"></iframe>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="custom-iframe">
|
||||||
|
import { reactive, watch } from 'vue';
|
||||||
|
import { isExternal } from '@/utils/validate';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
url: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['on-load']);
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
url: '',
|
||||||
|
loaded: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.url,
|
||||||
|
(val) => {
|
||||||
|
if (isExternal(val)) {
|
||||||
|
state.url = val;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoad = () => {
|
||||||
|
state.loaded = true;
|
||||||
|
emit('on-load', state.loaded);
|
||||||
|
};
|
||||||
|
</script>
|
@ -1,4 +1,5 @@
|
|||||||
import SvgIcon from './svg-icon';
|
import SvgIcon from './svg-icon';
|
||||||
|
import CustomIframe from './custom-iframe';
|
||||||
import CustomTableOperate from './custom-table-operate';
|
import CustomTableOperate from './custom-table-operate';
|
||||||
import CustomTableTree from './custom-table-tree';
|
import CustomTableTree from './custom-table-tree';
|
||||||
import CustomCarouselPicture from './custom-carousel-picture';
|
import CustomCarouselPicture from './custom-carousel-picture';
|
||||||
@ -16,6 +17,7 @@ import CustomEchartPie3d from './custom-echart-pie-3d';
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
SvgIcon,
|
SvgIcon,
|
||||||
|
CustomIframe,
|
||||||
CustomTableOperate,
|
CustomTableOperate,
|
||||||
CustomTableTree,
|
CustomTableTree,
|
||||||
CustomCarouselPicture,
|
CustomCarouselPicture,
|
||||||
|
@ -45,7 +45,7 @@ export function isHttp(url) {
|
|||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
export function isExternal(path) {
|
export function isExternal(path) {
|
||||||
return /^(https?:|mailto:|tel:)/.test(path);
|
return /^(http?:|https?:|mailto:|tel:)/.test(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user