Ocelot-Social/webapp/mixins/internalPageMixins.js
Wolfgang Huß e3ea3e1733 Fix error 'window is undefined' that appears sometimes
- Avoid possible errors, because of 'window' is only defined on browser side but not in NodeJS on client side. Check for 'typeof window' is neccessary, because if it's not defined at all you can't check for 'window !== undefined' without the same error 'window is undefined'.
2021-08-05 16:54:20 +02:00

22 lines
742 B
JavaScript

import InternalPage from '~/components/_new/features/InternalPage/InternalPage.vue'
export function internalPageMixins(pageParams) {
return {
layout: 'basic',
components: {
InternalPage,
},
data() {
return { pageParams }
},
created() {
if (!this.pageParams.isInternalPage) {
// to avoid possible errors, because 'window' is only defined on browser side but not in NodeJS on client side. check for 'typeof window' is neccessary, because if it's not defined at all you can't check for 'window !== undefined' without the same error 'window is undefined'
if (typeof window !== 'undefined') {
window.location.href = this.pageParams.externalLink
}
}
},
}
}