javascript — less.modifyVar () TypeError: Преобразование круговой структуры в JSON Anguar

less.modifyVar () TypeError: Преобразование круговой структуры в JSON Anguar

Я сталкиваюсь с проблемой преобразования круговой структуры в JSON при попытке динамического изменения стиля темы с помощью less.modifyVars() в приложении Angular.

JSP:

 {amp}lt;link rel="stylesheet/less" type="text/css" href="${pageContext.request.contextPath}/less/theme-style.less"/{amp}gt; {amp}lt;link rel="stylesheet/less" type="text/css" href="${pageContext.request.contextPath}/less/theme-variable.less"/{amp}gt; {amp}lt;script src="${pageContext.request.contextPath}/less/less.js"{amp}gt;{amp}lt;/script{amp}gt; 

Составная часть:

  changeHeader(event) { // let json = { // "@tb-header-bg": event.currentTarget.value // }; this.changeColor("@tb-header-bg", event.currentTarget.value); } changeColor = (variableName, colorCode) ={amp}gt; { ({amp}lt;any{amp}gt;window).less.modifyVars({ [variableName]: colorCode }); } 

variable.less

 @tb-header-bg :#012f46; 

style.less

 @import "./theme-variable.less"; .oed-page-wrapper .main-header .navbar-default { background: @tb-header-bg; //background : #f04615; } 

Ссылка: https://medium.com/@mzohaib.qc/ant-design-dynamic-runtime-theme-1f9a1a030ba0

ОБНОВИТЬ

Ошибка сейчас прерывистая. Когда я когда-нибудь обновляю страницу, она работает, и когда я вызываю modifyVar (), она загружает меньше файлов. Но если я обновлю страницу снова, то это показывает ошибку. Проблема в строке ниже в less.js:

 JSON.parse(JSON.stringify(a || {})); 

Выпуск:

 ERROR Error: Uncaught (in promise): TypeError: Converting circular structure to JSON --{amp}gt; starting at object with constructor 'b' | property 'less' -{amp}gt; object with constructor 'Object' --- property 'importManager' closes the circle TypeError: Converting circular structure to JSON --{amp}gt; starting at object with constructor 'b' | property 'less' -{amp}gt; object with constructor 'Object' --- property 'importManager' closes the circle at JSON.stringify ({amp}lt;anonymous{amp}gt;) at f (less.js:550) at i (less.js:618) at j (less.js:633) at less.js:709 at new ZoneAwarePromise (zone.js:891) at Object.m.refresh (less.js:693) at Object.m.modifyVars (less.js:688) at ThemeToolbar.changeColor (theme-toolbar.component.ts:62) at ThemeToolbar.changeHeader (theme-toolbar.component.ts:57) at Object.eval [as handleEvent] (theme-toolbar.component.template.html:121) at handleEvent (core.es5.js:11998) at callWithDebugContext (core.es5.js:13467) at Object.debugHandleEvent [as handleEvent] (core.es5.js:13055) at dispatchEvent (core.es5.js:8614) at core.es5.js:9228 at HTMLInputElement.{amp}lt;anonymous{amp}gt; (platform-browser.es5.js:2648) at ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.es5.js:3881) at ZoneDelegate.invokeTask (zone.js:420) at Zone.runTask (zone.js:188) at ZoneTask.invokeTask [as invoke] (zone.js:496) at invokeTask (zone.js:1540) at HTMLInputElement.globalZoneAwareCallback (zone.js:1566) at resolvePromise (zone.js:814) at new ZoneAwarePromise (zone.js:894) at Object.m.refresh (less.js:693) at Object.m.modifyVars (less.js:688) at ThemeToolbar.changeColor (theme-toolbar.component.ts:62) at ThemeToolbar.changeHeader (theme-toolbar.component.ts:57) at Object.eval [as handleEvent] (theme-toolbar.component.template.html:121) at handleEvent (core.es5.js:11998) at callWithDebugContext (core.es5.js:13467) at Object.debugHandleEvent [as handleEvent] (core.es5.js:13055) at dispatchEvent (core.es5.js:8614) at core.es5.js:9228 at HTMLInputElement.{amp}lt;anonymous{amp}gt; (platform-browser.es5.js:2648) at ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.es5.js:3881) at ZoneDelegate.invokeTask (zone.js:420) at Zone.runTask (zone.js:188) at ZoneTask.invokeTask [as invoke] (zone.js:496) at invokeTask (zone.js:1540) at HTMLInputElement.globalZoneAwareCallback (zone.js:1566) at ____________________Elapsed_6913_ms__At__Fri_Oct_18_2019_19_19_04_GMT_0530__India_Standard_Time_ () at Object.onScheduleTask (long-stack-trace-zone.js:108) at ZoneDelegate.scheduleTask (zone.js:401) at Object.onScheduleTask (zone.js:297) at ZoneDelegate.scheduleTask (zone.js:401) at Zone.scheduleTask (zone.js:232) at Zone.scheduleEventTask (zone.js:258) at XMLHttpRequest.addEventListener (zone.js:1831) at XMLHttpRequest.desc.set [as onabort] (zone.js:1244) at Object.send (jquery.min.js?bab7:4903) at ajax (jquery.min.js?bab7:4650) at entrybundle.js?v=2:23114 at Object.801.DBAPI.ajax (appobservable.js:1086) at Object.801.DBAPI.getDefaultTheme (appobservable.js:7316) at ThemeService.getDefaultThemeData (themeManagement.service.ts:11) at ThemePreview.ngOnInit (theme-preview.component.ts:20) at checkAndUpdateDirectiveInline (core.es5.js:10843) at checkAndUpdateNodeInline (core.es5.js:12341) at checkAndUpdateNode (core.es5.js:12284) at debugCheckAndUpdateNode (core.es5.js:13141) at debugCheckDirectivesFn (core.es5.js:13082) at Object.eval [as updateDirectives] (theme.template.html:95) at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:13067) at checkAndUpdateView (core.es5.js:12251) at callViewAction (core.es5.js:12599) at execComponentViewsAction (core.es5.js:12531) at checkAndUpdateView (core.es5.js:12257) at callWithDebugContext (core.es5.js:13467) at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.es5.js:13007) at ViewRef_.detectChanges (core.es5.js:10174) at core.es5.js:4812 at Array.forEach ({amp}lt;anonymous{amp}gt;) at ApplicationRef_.tick (core.es5.js:4812) at ApplicationRef_._loadComponent (core.es5.js:4787) at ApplicationRef_.bootstrap (core.es5.js:4775) at core.es5.js:4546 at Array.forEach ({amp}lt;anonymous{amp}gt;) at PlatformRef_._moduleDoBootstrap (core.es5.js:4546) at core.es5.js:4508 at ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.es5.js:3890) at ZoneDelegate.invoke (zone.js:387) at Zone.run (zone.js:138) at zone.js:872 at ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.es5.js:3881) at ZoneDelegate.invokeTask (zone.js:420) at Zone.runTask (zone.js:188) at drainMicroTaskQueue (zone.js:595) at ZoneTask.invokeTask [as invoke] (zone.js:500) at invokeTask (zone.js:1540) at XMLHttpRequest.globalZoneAwareCallback (zone.js:1566) at ____________________Elapsed_101_ms__At__Fri_Oct_18_2019_19_19_04_GMT_0530__India_Standard_Time_ () at Object.onScheduleTask (long-stack-trace-zone.js:108) at ZoneDelegate.scheduleTask (zone.js:401) at Object.onScheduleTask (zone.js:297) at ZoneDelegate.scheduleTask (zone.js:401) at Zone.scheduleTask (zone.js:232) at Zone.scheduleMicroTask (zone.js:252) at scheduleResolveOrReject (zone.js:862) at ZoneAwarePromise.then (zone.js:962) at core.es5.js:4507 at _callAndReportToErrorHandler (core.es5.js:4406) at core.es5.js:4504 at ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.es5.js:3890) at ZoneDelegate.invoke (zone.js:387) at Zone.run (zone.js:138) at NgZone.run (core.es5.js:3821) at PlatformRef_._bootstrapModuleFactoryWithZone (core.es5.js:4495) at core.es5.js:4537 at ZoneDelegate.invoke (zone.js:388) at Zone.run (zone.js:138) at zone.js:872 at ZoneDelegate.invokeTask (zone.js:421) at Zone.runTask (zone.js:188) at drainMicroTaskQueue (zone.js:595) at ZoneTask.invokeTask [as invoke] (zone.js:500) at invokeTask (zone.js:1540) at XMLHttpRequest.globalZoneAwareCallback (zone.js:1566) defaultErrorLogger @ core.es5.js:1020 
Понравилась статья? Поделиться с друзьями:
JavaScript & TypeScript
Adblock
detector