Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

6.9.0版本注入sdk.js后调用let amisLib = amisRequire('amis');会报错,需额外注入rest.js #11154

Open
dingwen1 opened this issue Nov 4, 2024 · 4 comments
Assignees

Comments

@dingwen1
Copy link

dingwen1 commented Nov 4, 2024

如果额外注入rest.js是正确操作,希望可以在文档中说明rest.js是负责哪些功能的。

@2betop
Copy link
Collaborator

2betop commented Nov 5, 2024

sdk 不要再二次编译了,直接 copy 过去,它内部有自己的加载逻辑,通过二次编译后反而不知道怎么加载了。

比如 vite 可以直接用这个插件 https://github.com/aisuda/vue2-amis-demo/blob/main/vite.config.js#L32-L39

@dingwen1
Copy link
Author

dingwen1 commented Nov 5, 2024

sdk 不要再二次编译了,直接 copy 过去,它内部有自己的加载逻辑,通过二次编译后反而不知道怎么加载了。

比如 vite 可以直接用这个插件 https://github.com/aisuda/vue2-amis-demo/blob/main/vite.config.js#L32-L39

可我就是直接从node_modules中拷出来的
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'node_modules/amis/sdk'),
to: './',
// 排除以点开头的文件(隐藏文件)
globOptions: {
dot: false,
ignore: ['**/.*'],
},
},
],
}),

@2betop 2betop changed the title 5.9.0版本注入sdk.js后调用let amisLib = amisRequire('amis');会报错,需额外注入rest.js 6.9.0版本注入sdk.js后调用let amisLib = amisRequire('amis');会报错,需额外注入rest.js Nov 5, 2024
@2betop
Copy link
Collaborator

2betop commented Nov 5, 2024

知道为何了。sdk 里面 amis 默认不是同步加载的了,要异步加载才能拿到比如 amisRequire(['amis'], (mod) => {})

也可以改成引入 amis-core 比如

const { normalizeLink } = amisRequire("amis-core");

https://github.com/aisuda/vue2-amis-demo 修改后可以正常渲染

参考:aisuda/vue2-amis-demo@1fea889

@2betop 2betop self-assigned this Nov 5, 2024
@dingwen1
Copy link
Author

dingwen1 commented Nov 5, 2024

知道为何了。sdk 里面 amis 默认不是同步加载的了,要异步加载才能拿到比如 amisRequire(['amis'], (mod) => {})

也可以改成引入 amis-core 比如

const { normalizeLink } = amisRequire("amis-core");

https://github.com/aisuda/vue2-amis-demo 修改后可以正常渲染

参考:aisuda/vue2-amis-demo@1fea889

好的,我试试。另外,那个文档上的sdk注册自定义插件的示例估计也会报错的

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants