1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
| <style lang="less">
| </style>
|
| <template>
| <div>
| <Card>
| <Row>
| <Form
| ref="searchForm"
| inline
| :label-width="70"
| @keydown.enter.native="handleGo"
| >
| <FormItem label="链接地址" prop="url">
| <Input
| type="text"
| v-model="url"
| placeholder="http://"
| clearable
| style="width: 350px"
| />
| </FormItem>
| <FormItem style="margin-left: -50px">
| <Button
| @click="handleGo"
| type="primary"
| icon="ios-send"
| style="margin-right: 5px"
| >前往</Button
| >
| <Button @click="handleOpen" icon="md-open">新窗口中打开</Button>
| </FormItem>
| </Form>
| </Row>
| <Divider style="margin-top: -10px; margin-bottom: 0px" />
| <div style="position: relative">
| <iframe
| id="iframe"
| :src="go"
| frameborder="0"
| width="100%"
| :height="height"
| scrolling="auto"
| ></iframe>
| <Spin fix size="large" v-if="loading"></Spin>
| </div>
| </Card>
| </div>
| </template>
|
| <script>
| export default {
| name: "monitor",
| data() {
| return {
| loading: false,
| go: "",
| url: "",
| html: "",
| height: "525px",
| };
| },
| computed: {},
| methods: {
| initUrl() {
| let url = this.$route.meta.url;
| if (url !== null && url !== undefined) {
| this.url = url;
| this.go = url;
| // window.open(this.go);
| this.loading = true;
| let that = this;
| // 判断iframe是否加载完毕
| let iframe = document.getElementById("iframe");
| if (iframe.attachEvent) {
| iframe.attachEvent("onload", function () {
| //iframe加载完成后你需要进行的操作
| that.loading = false;
| });
| } else {
| iframe.onload = function () {
| //iframe加载完成后你需要进行的操作
| that.loading = false;
| };
| }
| }
| },
| handleGo() {
| let url = this.url;
| this.go = this.url;
| },
| handleOpen() {
| window.open(this.url);
| },
| },
| watch: {
| $route(to, from) {
| this.initUrl();
| },
| },
| mounted() {
| // 计算高度
| let height = document.documentElement.clientHeight;
| this.height = Number(height - 217) + "px";
| this.initUrl();
| },
| };
| </script>
|
|