Appearance
常见问题
1. popup content-scripts之间数据如何互传
使用chrome内置的持久化存储
ts
await chrome.storage.local.get(['shopItem', 'platformItem', 'platformId']);
await chrome.storage.local.set({ shopItem: {} });
await chrome.storage.local.remove(['shopItem', 'platformItem', 'platformId']);2. 在content-scripts中某些element组件无法正常使用
- 部分组件 如:el-popover 自动绑定到宿主html中了 需要改成你 content-scripts 下index.ts中绑定的div。或者设置:teleported="false"
- ElMessage类似 你需要绑定到你的 root div上, 你可以自行封装一下
ts
export const contentScriptsMessage = (options: MessageParams, appContext?: null | AppContext) => {
ElMessage({ appendTo: root as HTMLElement, ...(options as any) }, appContext);
};