baidu / baidu/amis

引入 sdk.js 的 script 标签不能用defer属性?

Open
#10,892 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
18.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

加入`defer`属性后提示:`amisRequire is not defined`。

代码是官网的示例:

```

(function () {
let amis = amisRequire('amis/embed');
// 通过替换下面这个配置来生成不同页面
let amisJSON = {
type: 'page',
title: '表单页面',
body: {
type: 'form',
mode: 'horizontal',
api: '/saveForm',
body: [
{
label: 'Name',
type: 'input-text',
name: 'name'
},
{
label: 'Email',
type: 'input-email',
name: 'email'
}
]
}
};
let amisScoped = amis.embed('#root', amisJSON);
})();

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reported sdk.js example and compare how the two deferred script tags are loaded. Verify the behavior in a browser, focusing on when amisRequire becomes available; done means the example runs with defer on both tags without an "amisRequire is not defined" error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.