在由cli生成的工作区中,我具有根应用程序,该应用程序可以懒惰地加载许多应用程序(位于projects文件夹中)。
当我运行“ ng build root-application”时,所有块都放在dist / root-application文件夹中,我可以将此文件夹复制到我的服务器上,我们很高兴。
但是,这些应用程序几乎在开发生命周期中从未处于同一阶段(仍在开发中,有些还在进行质量保证),我希望能够隔离地部署它们,而不必部署整个站点。
有人对此有策略吗?
在我的测试中,组件接收其 props 并设置组件。
这会触发 useEffect 发出 http 请求(我模拟)。
返回获取的模拟 resp 数据,但 useEffect 内的清理函数已被调用(因此组件已卸载),因此我收到所有这些错误。
如何防止组件卸载以便更新状态?我尝试过采取行动,没有采取行动,没有任何原因导致组件等待获取完成。
我应该说我的警告只是警告,但我不喜欢所有的红色,它表明出了问题。
export const BalanceModule = (props) => {
const [report, setReport] = useState();
useEffect(() => {
fetch('http://.....').then((resp) => {
console.log("data returned!!!")
setReports((report) => {
return {...report, data: resp}
})
})
return () => {
console.log("unmounted!!!")
};
}, [report])
.... trigger update on report here
}
// the test:
test("simplified-version", async () => {
act(() => {
render(
<BalanceModule {...reportConfig}></BalanceModule>
);
});
await screen.findByText("2021-01-20T01:04:38");
expect(screen.getByText("2021-01-20T01:04:38")).toBeTruthy();
});
Run Code Online (Sandbox Code Playgroud) 我从这个问题中分叉并编辑了一个plunker
我想要做的是在数据加载后让SELECT元素(组合框)更新/填充,但有些事情是不对的.我检索数据,它在SELECT元素的范围内,但模板不刷新以显示数据.有人可以找我,告诉我为什么模板不刷新?
非常感谢.
指令:
app.directive('walkmap', function() {
return {
restrict: 'A',
transclude: true,
scope: { walks: '=walkmap' },
template: '<select data-ng-options="w.postalCode for w in walks"></select>',
link: function(scope, element, attrs)
{
scope.$watch('walks', function (walks) {
scope.walks = walks;
console.log('watch triggered');
console.log(scope.walks);
});
}
};
});
Run Code Online (Sandbox Code Playgroud)
Index.html:
<body ng-controller="MainCtrl">
<h1>The Walks Data:</h1>
<div walkmap="store.walks"></div>
</body>
Run Code Online (Sandbox Code Playgroud) 我的 package.json 包含此脚本:
"test:ci": "ng test --no-watch --no-progress --browsers ChromeHeadless"
如果我运行npm run test:ci所有测试都会通过,但退出时会显示
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! exotics-client@0.0.0 test:ci: `ng test --no-watch --no-progress --browsers ChromeHeadless`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the exotics-client@0.0.0 test:ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Run Code Online (Sandbox Code Playgroud)
如果我在
ng test --no-watch --no-progress --browsers ChromeHeadless
不使用 npm 的情况下运行,测试都会再次通过,并且不会返回错误。
还有其他人看到这个问题吗?知道是什么原因造成的吗?
我知道为什么我会看到这个错误,这是因为我的一些错误locationDeletionDate是“9999-12-31 00:00:00.0000000”,并且将 90 天添加到locationDeletionDate(正如我在查询中所做的那样)会导致标题中的错误:
...WHERE
(bpj.JobStatus = 'Live')
AND (l.locationEffectiveDate <= SYSDATETIME())
AND (dateadd(d,90,l.locationDeletionDate) >= SYSDATETIME())...
Run Code Online (Sandbox Code Playgroud)
我想我需要的是CASE我的WHERE-clause 中的条件,以确保添加 90 天后日期不会出错?或者有更优雅的方式吗?
angular ×1
angular-cli ×1
angularjs ×1
chunks ×1
dateadd ×1
deployment ×1
jasmine ×1
reactjs ×1
refresh ×1
sql ×1
sql-server ×1
templates ×1
use-effect ×1
webpack ×1