如果用户成功创建项目,我将使用新的 ScaffoldMessenger 来显示小吃栏。在显示小吃店时,我将应用导航到仪表板。但是一旦它点击仪表板,就会抛出一个子树错误中共享相同标签的多个英雄。我没有在仪表板中使用任何 Hero 小部件,我有一个 FloatingActionButton 但它的 hero 参数设置为 null。
示例代码:
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('A SnackBar has been shown.'),
animation: null,
),
);
Navigator.pushReplacementNamed(context, '/dashboard');
Run Code Online (Sandbox Code Playgroud)
这导致此错误:
The following assertion was thrown during a scheduler callback:
There are multiple heroes that share the same tag within a subtree.
Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), each Hero must have a unique non-null tag.
In this case, multiple heroes …Run Code Online (Sandbox Code Playgroud) fetch api 非常有用,但不幸的是它不适用于大多数浏览器,尤其是 Internet Explorer。我尝试使用 babel 将我的代码从 es6 转换为 es5,但它没有解决这个问题。转换成es5的时候还是包含fetch的。我怎样才能解决这个问题。这是es6代码:
var btnText = document.getElementById('btnText');
var btnJson = document.getElementById('btnJson');
btnText.addEventListener("click",fetchBtnText);
function fetchBtnText() {
fetch("sample.txt")
.then((response) => response.text())
.then((data) => console.log(data))
}
Run Code Online (Sandbox Code Playgroud)
这是到es5的转换
'use strict';
var btnText = document.getElementById('btnText');
var btnJson = document.getElementById('btnJson');
btnText.addEventListener("click", fetchBtnText);
function fetchBtnText() {
fetch("sample.txt").then(function (response) {
return response.text();
}).then(function (data) {
return console.log(data);
});
}
Run Code Online (Sandbox Code Playgroud)