Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
d76cfd7f
Unverified
Commit
d76cfd7f
authored
Aug 01, 2021
by
yanzhuang
Committed by
GitHub
Aug 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix iframe heigth error (#1012)
parent
2fd0fd28
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
30 deletions
+14
-30
index.vue
src/views/sys/iframe/index.vue
+14
-30
No files found.
src/views/sys/iframe/index.vue
View file @
d76cfd7f
<
template
>
<
template
>
<div
:class=
"prefixCls"
:style=
"getWrapStyle"
>
<div
:class=
"prefixCls"
:style=
"getWrapStyle"
>
<Spin
:spinning=
"loading"
size=
"large"
:style=
"getWrapStyle"
>
<Spin
:spinning=
"loading"
size=
"large"
:style=
"getWrapStyle"
>
<iframe
:src=
"frameSrc"
:class=
"`$
{prefixCls}__main`" ref="frameRef">
</iframe>
<iframe
:src=
"frameSrc"
:class=
"`$
{prefixCls}__main`"
ref="frameRef"
@load="hideLoading"
>
</iframe>
</Spin>
</Spin>
</div>
</div>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
type
{
CSSProperties
}
from
'
vue
'
;
import
type
{
CSSProperties
}
from
'
vue
'
;
import
{
defineComponent
,
ref
,
unref
,
onMounted
,
nextTick
,
computed
}
from
'
vue
'
;
import
{
defineComponent
,
ref
,
unref
,
computed
}
from
'
vue
'
;
import
{
Spin
}
from
'
ant-design-vue
'
;
import
{
Spin
}
from
'
ant-design-vue
'
;
import
{
getViewportOffset
}
from
'
/@/utils/domUtils
'
;
import
{
useWindowSizeFn
}
from
'
/@/hooks/event/useWindowSizeFn
'
;
import
{
useWindowSizeFn
}
from
'
/@/hooks/event/useWindowSizeFn
'
;
import
{
propTypes
}
from
'
/@/utils/propTypes
'
;
import
{
propTypes
}
from
'
/@/utils/propTypes
'
;
import
{
useDesign
}
from
'
/@/hooks/web/useDesign
'
;
import
{
useDesign
}
from
'
/@/hooks/web/useDesign
'
;
import
{
useLayoutHeight
}
from
'
/@/layouts/default/content/useContentViewHeight
'
;
export
default
defineComponent
({
export
default
defineComponent
({
name
:
'
IFrame
'
,
name
:
'
IFrame
'
,
...
@@ -24,10 +28,11 @@
...
@@ -24,10 +28,11 @@
frameSrc
:
propTypes
.
string
.
def
(
''
),
frameSrc
:
propTypes
.
string
.
def
(
''
),
},
},
setup
()
{
setup
()
{
const
loading
=
ref
(
fals
e
);
const
loading
=
ref
(
tru
e
);
const
topRef
=
ref
(
50
);
const
topRef
=
ref
(
50
);
const
heightRef
=
ref
(
window
.
innerHeight
);
const
heightRef
=
ref
(
window
.
innerHeight
);
const
frameRef
=
ref
<
HTMLFrameElement
|
null
>
(
null
);
const
frameRef
=
ref
<
HTMLFrameElement
>
();
const
{
headerHeightRef
}
=
useLayoutHeight
();
const
{
prefixCls
}
=
useDesign
(
'
iframe-page
'
);
const
{
prefixCls
}
=
useDesign
(
'
iframe-page
'
);
useWindowSizeFn
(
calcHeight
,
150
,
{
immediate
:
true
});
useWindowSizeFn
(
calcHeight
,
150
,
{
immediate
:
true
});
...
@@ -43,8 +48,7 @@
...
@@ -43,8 +48,7 @@
if
(
!
iframe
)
{
if
(
!
iframe
)
{
return
;
return
;
}
}
let
{
top
}
=
getViewportOffset
(
iframe
);
const
top
=
headerHeightRef
.
value
;
top
+=
20
;
topRef
.
value
=
top
;
topRef
.
value
=
top
;
heightRef
.
value
=
window
.
innerHeight
-
top
;
heightRef
.
value
=
window
.
innerHeight
-
top
;
const
clientHeight
=
document
.
documentElement
.
clientHeight
-
top
;
const
clientHeight
=
document
.
documentElement
.
clientHeight
-
top
;
...
@@ -56,33 +60,13 @@
...
@@ -56,33 +60,13 @@
calcHeight
();
calcHeight
();
}
}
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
{
return
{
getWrapStyle
,
getWrapStyle
,
loading
,
loading
,
frameRef
,
frameRef
,
prefixCls
,
prefixCls
,
hideLoading
,
};
};
},
},
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment