asp.net核心,角度2,PrimeNG [英] asp.net core, angular 2, PrimeNG

查看:80
本文介绍了asp.net核心,角度2,PrimeNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 aspnetcore-spa模板作为创建管理面板的起点. 接下来,我添加 PrimeNG 库以使用其组件.

I use aspnetcore-spa template as starting point to create admin panel. Next I add PrimeNG library to use it's components.

不幸的是,当我将ButtonModule导入app.module.ts并刷新时,出现错误``事件未定义''.我不知道几天的原因是什么,所以有人可以帮助我吗?

Unfortunately, when I import i.e. ButtonModule to app.module.ts and refresh, I get an error 'Event is undefined'. I can't figure out what is the reason for several days, so can anyone help me?

更新

  • 所以首先我用yo aspnetcore-spa
  • 生成存根
  • 下一个npm install font-awesome primeng --save
  • 然后我将font-awesome和PrimeNG css文件添加到webpack.config.vendor.js

  • So first of all I generate the stub with yo aspnetcore-spa
  • Next npm install font-awesome primeng --save
  • Then I add font-awesome and PrimeNG css files to webpack.config.vendor.js

 vendor: [
    '@angular/common',
    '@angular/compiler',
    '@angular/core',
    '@angular/http',
    '@angular/platform-browser',
    '@angular/platform-browser-dynamic',
    '@angular/router',
    '@angular/platform-server',
    'angular2-universal',
    'angular2-universal-polyfills',
    'bootstrap',
    'bootstrap/dist/css/bootstrap.css',
    'es6-shim',
    'es6-promise',
    'event-source-polyfill',
    'jquery',
    'zone.js',            
    'font-awesome/css/font-awesome.css',
    'primeng/resources/themes/sunny/theme.css',
    'primeng/resources/primeng.css'
]

  • 重建供应商依赖项webpack --config webpack.config.vendor.js

    现在,如果我启动该应用程序,我将获得异常

    Now if I start the app I'll get exception

    此代码段的异常点

     __decorate([
        core_1.HostListener('mouseenter', ['$event']), 
        __metadata('design:type', Function), 
        __metadata('design:paramtypes', [Event]), 
        __metadata('design:returntype', void 0)
    

    更新2

    我发现问题出在服务器端渲染中,因此我将其删除.它对我有用,但是在不打开服务器端渲染的情况下解决该问题仍然很有趣.

    I've figured out that problem was in server-side rendering, so I removed it. It works for me, but it is still interesting how to solve this without turning of server-side rendering.

    推荐答案

    <app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
    
    <app>Loading...</app>

    您需要从index.cshtml的服务器端禁用预渲染.

    you need to disable the pre render from the server side, from index.cshtml.

    更改

    <app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
    

    <app>Loading...</app>
    

    这篇关于asp.net核心,角度2,PrimeNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆