Jquery asp.net核心spa模板,语义用户界面

Jquery asp.net核心spa模板,语义用户界面,jquery,.net,angular,ng2-semantic-ui,Jquery,.net,Angular,Ng2 Semantic Ui,我无法使语义ui与Microsoft.AspNetCore.SpaTemplate一起工作 当我创建Angular CLI应用程序时,它工作正常,但我希望将其打包在一起 我所做的: 1) 安装SPA模板:dotnet新建--安装Microsoft.AspNetCore.spattemplates:* 2) 创建新项目:dotnet new angular 3) 安装所有DEP:npm安装 4) 添加语义iu css:npm i语义ui css——保存 5) 添加ng2语义界面:npm i ng2

我无法使语义ui与Microsoft.AspNetCore.SpaTemplate一起工作

当我创建Angular CLI应用程序时,它工作正常,但我希望将其打包在一起

我所做的:

1) 安装SPA模板:dotnet新建--安装Microsoft.AspNetCore.spattemplates:*
2) 创建新项目:dotnet new angular
3) 安装所有DEP:npm安装
4) 添加语义iu css:npm i语义ui css——保存 5) 添加ng2语义界面:npm i ng2语义界面——保存 6) 将'semantic-ui-css/semantic.css''ng2-semantic-ui'添加到webpack.config.vendor.js
7) 运行
webpack--config webpack.config.vendor.js
重建vendor.js
8) 将“eot | woff | woff2 | ttf”添加到webpack.config.js中的URL加载器
9) 在app.module.client.ts中导入“ng2-semantic-ui”

当我运行应用程序时,会出现以下异常:

未捕获错误:模块“AppModule”导入了意外值“suimule”。请添加@NgModule注释。

这是我的代码:
home.component.ts

import { Component } from '@angular/core';
import { SuiModule } from 'ng2-semantic-ui';

@Component({
    selector: 'home',
    templateUrl: './home.component.html'
})
export class HomeComponent {
}
home.component.html:

<sui-accordion class="styled fluid">
    <sui-accordion-panel>
        <div title>
            <i class="dropdown icon"></i>
            First Panel
        </div>
        <div content>
            <p>Add classes to the <code>sui-accordion</code> element to apply styles.</p>
        </div>
    </sui-accordion-panel>
    <sui-accordion-panel>
        <div title>
            <i class="dropdown icon"></i>
            Second Panel
        </div>
        <div content>
            <p>Second panel content.</p>
        </div>
    </sui-accordion-panel>
</sui-accordion>
app.module.client.ts:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { sharedConfig } from './app.module.shared';
import { SuiModule} from 'ng2-semantic-ui';

@NgModule({
    bootstrap: sharedConfig.bootstrap,
    declarations: sharedConfig.declarations,
    imports: [
        BrowserModule,
        FormsModule,
        HttpModule,
        SuiModule,
        ...sharedConfig.imports
    ],
    providers: [
        { provide: 'ORIGIN_URL', useValue: location.origin }
    ]
})
export class AppModule {
}
webpack.config.vendor.js

const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const merge = require('webpack-merge');

module.exports = (env) => {
    const extractCSS = new ExtractTextPlugin('vendor.css');
    const isDevBuild = !(env && env.prod);
    const sharedConfig = {
        stats: { modules: false },
        resolve: { extensions: [ '.js' ] },
        module: {
            rules: [
                { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, use: 'url-loader?limit=100000' }
            ]
        },
        entry: {
            vendor: [
                '@angular/animations',
                '@angular/common',
                '@angular/compiler',
                '@angular/core',
                '@angular/forms',
                '@angular/http',
                '@angular/platform-browser',
                '@angular/platform-browser-dynamic',
                '@angular/router',
                'semantic-ui-css/semantic.css',
                'ng2-semantic-ui',
                'es6-shim',
                'es6-promise',
                'event-source-polyfill',
                'jquery',
                'zone.js',
            ]
        },
        output: {
            publicPath: '/dist/',
            filename: '[name].js',
            library: '[name]_[hash]'
        },
        plugins: [
            new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
            new webpack.ContextReplacementPlugin(/\@angular\b.*\b(bundles|linker)/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/11580
            new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)@angular/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/14898
            new webpack.IgnorePlugin(/^vertx$/) // Workaround for https://github.com/stefanpenner/es6-promise/issues/100
        ]
    };

    const clientBundleConfig = merge(sharedConfig, {
        output: { path: path.join(__dirname, 'wwwroot', 'dist') },
        module: {
            rules: [
                { test: /\.css(\?|$)/, use: extractCSS.extract({ use: isDevBuild ? 'css-loader' : 'css-loader?minimize' }) }
            ]
        },
        plugins: [
            extractCSS,
            new webpack.DllPlugin({
                path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
                name: '[name]_[hash]'
            })
        ].concat(isDevBuild ? [] : [
            new webpack.optimize.UglifyJsPlugin()
        ])
    });

    const serverBundleConfig = merge(sharedConfig, {
        target: 'node',
        resolve: { mainFields: ['main'] },
        output: {
            path: path.join(__dirname, 'ClientApp', 'dist'),
            libraryTarget: 'commonjs2',
        },
        module: {
            rules: [ { test: /\.css(\?|$)/, use: ['to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] } ]
        },
        entry: { vendor: ['aspnet-prerendering'] },
        plugins: [
            new webpack.DllPlugin({
                path: path.join(__dirname, 'ClientApp', 'dist', '[name]-manifest.json'),
                name: '[name]_[hash]'
            })
        ]
    });

    return [clientBundleConfig, serverBundleConfig];
}

可能是你的jquery没有包含在语义ui插件之前,所以如果我添加import'jquery',它就不起作用;在app.module.client.ts中使用语义之前:引导程序工作得很好,也使用jQuery??好-让它工作了。。。必须升级到ng2语义用户界面0.9.4、Angular 4.3.1和index.cshtml中:“加载…”可能是您的jquery在语义用户界面插件之前不包括在内,因此如果我添加导入“jquery”,则无法工作;在app.module.client.ts中使用语义之前:引导程序工作得很好,也使用jQuery??好-让它工作了。。。不得不升级到ng2语义用户界面0.9.4、Angular 4.3.1和index.cshtml中的“加载…”