url的搜索参数去判断,例如新增参数embed
<iframe
src="https://test.com/#/main?id=66"
width="100%"
height="100%"
frameBorder={0}
/>
<iframe
src="https://test.com/?embed=csdn#/main?id=66"
width="100%"
height="100%"
frameBorder={0}
/>
embed参数并进行相应判断和使用/**
* 是否处于嵌入模式
*/
export function isEmbed() {
const usp = new URLSearchParams(window.location.search);
return usp.has('embed');
}
/**
* 被哪个平台所嵌入
*/
export function getEmbed() {
const usp = new URLSearchParams(window.location.search);
return usp.get('embed');
}