Closed ultranana closed 1 year ago
沙箱不生效怎么办
第一个模块组件:
import * as React from 'react';
type ComponentProps = {
title: string,
};
export default function Ask(props: ComponentProps) {
const { type, ...others } = props;
window.a = 1
console.log("ask", a)
return (
<div className="Ask" {...others}>Hello Ask</div>
);
}
第二个模块组件:
import * as React from 'react';
type ComponentProps = {
title: string,
};
export default function Examle(props: ComponentProps) {
const { type, ...others } = props;
console.log(window.a)
return (
<div className="Examle" {...others}>Hello Examle</div>
);
}
使用的代码
import React from 'react'
import { MicroModule, registerModules, getModules } from '@ice/stark-module';
registerModules([
{
name: 'Ask',
url: 'http://localhost:3334/index/index.js',
},
{
url: 'http://localhost:3333/index/index.js',
name: 'Example',
},
]);
const App = () => {
return <div>
<MicroModule moduleName="Example" sandbox/>
<MicroModule moduleName="Ask" sandbox/>
</div>;
}
export default App
部分情况下是这样的,加上sanbox了,感觉和js加载顺序有关系
业务上试用了一下微模块@ice/stark-module,但是发现没有对js做沙箱隔离。我也没有找到启用沙箱的对应api,能否提供下