排名
1
文章
860
粉丝
112
评论
163
.net core自定义项目模板,创建自己的模板项目,使用命令行创建模板项目
尘叶心繁 : 可以可以讲真的我都想弄个模板
net core webapi post传递参数
庸人 :
确实坑哈,我也是下班好了好几次,发现后台传递对象是可以的,但...
.net webapi 返回需要的字段,忽略某些字段,修改字段名等
雨雨雨雨雨辰 : 已精
.net webapi 返回需要的字段,忽略某些字段,修改字段名等
雨雨雨雨雨辰 :
疯狂反射
百度编辑器自定义模板
庸人 : 我建议换个编辑器,因为现在百度富文本已经停止维护了,用tinymec...
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术
原
windows对象中获取vue对象。vue中使用iframe页面嵌套后,嵌套页里边页面跳转问题,实现外层路由的跳转,实现打开新的tab页面

某些情况下使用iframe可以降低一下耦合度,分隔开项目,不会让一个项目越来越大。
vue嵌套iframe页面的方法
比如这里的path就是需要使用iframe打开的路由,是因为路由的规则就是这样设置的
这一串:routerPath
里边的内容才是真正iframe引用的内容,也就是这一串内容
贴一下主项目那个iframe的实现:
<template>
<div>
<iframe ref="iframe" v-loading.fullscreen.lock="fullscreenLoading" :src="getUrlPath()" class="iframe" />
</div>
</template>
<script>
export default {
components: {},
props: {
routerPath: {
type: String,
default: ''
}
},
data() {
return {
fullscreenLoading: false,
urlPath: this.getUrlPath()
}
},
watch: {
routerPath: function(val) {
console.log(val)
this.urlPath = this.getUrlPath()
}
},
created() {
this.src = this.$route.query
console.log('ifram', this.$route)
this.fullscreenLoading = false
},
mounted() {
console.log(this.$route, this.routerPath)
this.iframeInit()
window.onresize = () => {
this.iframeInit()
}
// 方法让子页面可以调用
window.jumpUrl = this.jumpUrl
},
methods: {
jumpUrl(_path, _query) {
// 进行页面跳转
this.$router.push({
path: _path,
query: _query
})
// router.push({
// path: '/task_report/schoolMonthTaskReport',
// query: {
// dateTime: _dateParamDay,
// type: _type,
// dateParamChoise: state.dateParamChoise,
// isJumpQueryDetails: "1"
// }
// })
},
iframeInit() {
const iframe = this.$refs.iframe
const clientHeight = document.documentElement.clientHeight - 90
iframe.style.height = `${clientHeight}px`
if (iframe.attachEvent) {
iframe.attachEvent('onload', () => {
this.fullscreenLoading = false
})
} else {
iframe.onload = () => {
this.fullscreenLoading = false
}
}
},
getUrlPath: function() {
// let url = window.location.href
let url = `/${this.$route.params.routerPath}`
// url = url.replace('/iframe', '')
var timstamp = (new Date()).valueOf()
if (url.indexOf('?') >= 0) {
url = url + '&t=' + timstamp
} else {
url = url + '?t=' + timstamp
}
console.log(url)
return url
}
}
}
</script>
<style>
.iframe {
width: 100%;
height: 100%;
border: 0;
overflow: hidden;
box-sizing: border-box;
}
</style>
vue中使用iframe页面嵌套后,嵌套页里边页面跳转不会在外部项目打开tab页面,只会在iframe页面里边刷新因为他其实是不同的项目,要实现外层路由的跳转,实现打开新的tab页面,肯定要想办法能操作到主项目的vue对象也就是外层项目的vue对象,一般有两种实现方法。
一种是在iframe中嵌套获取顶层的vue对象,获取到vue对象就可以操作路由进行页面跳转了
在主项目中,main.js里边把vue的对象存放到windows里边去。
然后嵌套的iframe页面里边就可以使用window.top.vm获取到顶层的vue对象了
获取到顶层对象了就可以进行正常情况的跳转了。
还有一种就是在主项目提供一个方法,让嵌套的iframe页面来调用方法
参考:https://blog.csdn.net/pk694046220/article/details/128578108
mounted() {
console.log(this.$route, this.routerPath)
this.iframeInit()
window.onresize = () => {
this.iframeInit()
}
// 方法让子页面可以调用
window.jumpUrl = this.jumpUrl
},
methods: {
jumpUrl(_path, _query) {
// 进行页面跳转
this.$router.push({
path: _path,
query: _query
})
// router.push({
// path: '/task_report/schoolMonthTaskReport',
// query: {
// dateTime: _dateParamDay,
// type: _type,
// dateParamChoise: state.dateParamChoise,
// isJumpQueryDetails: "1"
// }
// })
}
}
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)
评价