我有 2 个应用程序管理外壳和交付管理,我正在使用多区域来处理 NextJs 中的问题。
这两个应用程序都使用带有导航链接的共享标头,但我在从一个区域导航到另一个区域时遇到问题。
Admin-Shell使用 next.config.js 文件在端口 4201 上运行
module.exports = {
basePath: '/main',
rewrites: async() => {
return [{
source: '/delivery-management',
destination: `http://localhost:4202/delivery-management`,
basePath: false,
},
{
source: '/delivery-management/:path*',
destination: `http://localhost:4202/delivery-management/:path*`,
basePath: false,
},
];
},
};
Run Code Online (Sandbox Code Playgroud)
使用 next.config.js 文件在端口 4202 上运行的交付管理
module.exports = {
basePath: '/delivery-management',
rewrites: async() => {
return [{
source: '/main',
destination: `http://localhost:4201/main`,
basePath: true,
},
{
source: '/main',
destination: `http://localhost:4201/main/:path*`,
basePath: true,
},
];
},
}; …Run Code Online (Sandbox Code Playgroud) 我正在创建 NgRx 应用程序,但我对它的实现感到很困惑,因为它是我第一个使用 NgRx 的应用程序。我有一家带有“公司”状态的商店。我必须搜索这些公司,如果找到就返回。如果没有找到所需的公司,它应该调用 API 并同样地获取结果,但该过程是循环的并且运行无限时间。
这是我的代码:
this.companySearchCtrl.valueChanges
.pipe(
debounceTime(300),
distinctUntilChanged()
)
.subscribe(val => {
if (val !== ' ' || val !== '') {
this.store.select(getCompanys).subscribe(data => {
console.log(data);
//filter companies on the basis of search text
const filteredData = data.filter(x =>
x['name']
.toLowerCase()
.startsWith(this.companySearchCtrl.value.toLowerCase())
);
console.log(filteredData);
if (filteredData.length === 0) { //if data is not found in store
console.log('got a call');
this.store.dispatch(
new CompanyActions.find({
where: { name: { regexp: `${val}/i` } } // call to API …Run Code Online (Sandbox Code Playgroud)