服务器端呈现:ERROR TypeError:scrollTargetElement.getBoundingClientRect不是函数。角度通用

时间:2018-05-21 13:28:02

标签: angular5

我正在尝试将通用放在我的应用程序中,当我运行命令(npm run build)时,它会显示以下错误。

ERROR TypeError: scrollTargetElement.getBoundingClientRect is not a function
    at Function.PageScrollUtilService.extractElementPosition (/var/www/html/rcycnewPranab/RCYC/presentation/angular/rcyc/dist/server.js:40723:39)
    at PageScrollInstance.extractScrollTargetPosition (/var/www/html/rcycnewPranab/RCYC/presentation/angular/rcyc/dist/server.js:146924:109)
    at PageScrollService.start (/var/www/html/rcycnewPranab/RCYC/presentation/angular/rcyc/dist/server.js:40568:55)
    at AppComponent../src/app/app.component.ts.AppComponent.onActivate (/var/www/html/rcycnewPranab/RCYC/presentation/angular/rcyc/dist/server.js:182016:32)

用于滚动我在我的应用程序中使用Ng2PageScrollModule。它将通过创建它的实例滚动到特定目标。

onActivate() {
 let pageScrollInstance: PageScrollInstance = PageScrollInstance.simpleInstance(this.document,'#topPage');
 this.pageScrollService.start(pageScrollInstance);
}

webpack.config

const path = require('path');
const webpack = require('webpack');

module.exports = {
  entry: {
    server: './server.ts'
  },
  resolve: {
    extensions: ['.ts', '.js'],
    alias: {
      'main.server': path.join(__dirname, 'dist', 'server', 'main.bundle.js')
    }
  },
  target: 'node',

  externals: [/node_modules/],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].js'
  },
  module: {
    rules: [{
    },
      { test: /\.ts$/, loader: 'ts-loader' }
    ]
  },
    plugins: [
    // Temporary Fix for issue: https://github.com/angular/angular/issues/11580
    // for "WARNING Critical dependency: the request of a dependency is an expression"
    new webpack.ContextReplacementPlugin(
      /(.+)?angular(\\|\/)core(.+)?/,
      path.join(__dirname, 'src'), // location of your src
      {} // a map of your routes
    ),
    new webpack.ContextReplacementPlugin(
      /(.+)?express(\\|\/)(.+)?/,
      path.join(__dirname, 'src'),
      {}
    )
  ]

}

我该如何解决这个问题?

0 个答案:

没有答案