Commit e4acb092 authored by “yiyousong”'s avatar “yiyousong”

pref:修改预览应用

parent 4377dc17
......@@ -17,7 +17,7 @@
<iframe
name="myIframe"
style="width: 100%; height: 100%"
:src="previewInfo.previewUrl"
:src="previewUrl"
frameborder="0"
></iframe>
</div>
......@@ -28,48 +28,21 @@ export default {
data() {
return {
previewInfo: this.$route.query,
isReady: false,
previewUrl: "",
};
},
created() {
// 接收子级返回首页指令
// window.onmessage = (res) => {
// if (res.data.message === "返回首页") {
// this.$router.push("/");
// }
// };
window.addEventListener("message", this.getChildrenMsg);
},
watch: {
isReady(newVal) {
if (newVal) {
this.sendInfo();
}
},
this.sendInfo();
},
methods: {
getChildrenMsg(res) {
if (res.data.type === "childStatus") {
this.isReady = res.data.isReady;
}
},
sendInfo() {
let obj = {
type: "siteInfo",
siteId: this.previewInfo.siteId,
appId: this.previewInfo.appId,
};
let siteId = this.previewInfo.siteId;
let appId = this.previewInfo.appId;
this.previewUrl = `${this.previewInfo.previewUrl}?siteId=${siteId}&appId=${appId}`;
/* eslint-disable */
myIframe.window.postMessage(obj, "*");
},
handleBack() {
this.$router.back();
// myIframe.window.postMessage(obj, "*");
},
},
beforeDestroy() {
window.removeEventListener("message", this.getChildrenMsg);
},
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment