我知道Google引用错误即将到来的原因是因为在服务器上执行的sever.js确实在其范围内定义了google。我正在寻找一种解决此错误的方法。
运行npm run serve:ssr
后,它会显示
task: ZoneTask {
_zone: Zone {
_parent: [Zone],
_name: 'angular',
_properties: [Object],
_zoneDelegate: [ZoneDelegate]
},
runCount: 0,
_zoneDelegates: null,
_state: 'notScheduled',
type: 'microTask',
source: 'Promise.then',
data: ZoneAwarePromise [Promise] {
__zone_symbol__state: 0,
__zone_symbol__value: ReferenceError: google is not defined
at new exports.ListingsComponent (/home/abhishek/projects/website/dist/server.js:50760:350264)
at createClass (/home/abhishek/projects/website/dist/server.js:79119:20)
at createDirectiveInstance (/home/abhishek/projects/website/dist/server.js:78988:20)
at createViewNodes (/home/abhishek/projects/website/dist/server.js:87348:36)
at createRootView (/home/abhishek/projects/website/dist/server.js:87262:5)
at Object.createProdRootView [as createRootView] (/home/abhishek/projects/website/dist/server.js:87774:12)
at ComponentFactory_.create (/home/abhishek/projects/website/dist/server.js:78467:29)
at RouterOutlet.activateWith (/home/abhishek/projects/website/dist/server.js:183250:40)
},
scheduleFn: undefined,
cancelFn: undefined,
callback: [Function],
invoke: [Function]
`
我需要在server.ts中用有效值定义google以避免此错误。在节点级别上导入Google的任何转变都会有所帮助。是否有任何package
或module
可以帮助我