简体   繁体   English

Angular 4 Webpack 2&AOT:意外结束标记“a”

[英]Angular 4 Webpack 2 & AOT: Unexpected closing tag “a”

I am getting this weird error when I am making a build, at the time of watch or running server its not giving anything, just only at the time of build giving this error: 我正在制作一个构建时遇到这个奇怪的错误,在观看或运行服务器时它没有给出任何东西,只是在构建时给出了这个错误:

Unexpected closing tag "a". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags ("ref=/user><img class="d-inline-block align-top" [src]="staticUrl + 'v4/img/intouch-logo-name.png'"/>[ERROR ->]</a> <search class="mr-auto col-sm-7 col-md-6 col-lg-5 col-xl-5 p-0"></search> <div id=settings> <div"): ng:///Users/header.html@0:192

And here is my html: 这是我的HTML:

<nav class="navbar d-flex flex-row navbar-light bg-faded fixed-top">
    <a class="navbar-brand" href="/user"><img class="d-inline-block align-top" [src]="staticUrl + 'v4/img/intouch-logo-name.png'" /></a>

    <search class="mr-auto col-sm-7 col-md-6 col-lg-5 col-xl-5 p-0"></search>

    <div id="settings">
        <div class="dropdown clearfix">
            <div class="userProfile dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <div class="userDetail">
                    <label>
                        {{loggedUser.icontact.name.given + ((loggedUser.icontact.name.family) ? ' '+loggedUser.icontact.name.family : '')}}
                    </label>
                    <small>
                        {{loggedUser.icontact.user_iid}}
                    </small>
                </div>
                <img class="profilePic rounded-circle" [src]="(loggedUser.icontact.photo) ? loggedUser.icontact.photo.url : staticUrl + 'images/in_img_default_profile_100px.png'" />
            </div>
            <div class="dropdown-menu" aria-labelledby="settings">
                <a class="dropdown-item" [href]="'/' + loggedUser.icontact.user_iid" target="_blank">View profile</a>
                <a class="dropdown-item" href="/user/cards/" target="_blank">
                    Edit Profile
                </a>
                <div class="dropdown-divider"
                    *ngIf="accountInfo.userStatus.currentUserType == accountInfo.userStatus.groupType"></div>
                <a class="dropdown-item" href="/user/notices/" target="_blank"
                    *ngIf="accountInfo.userStatus.currentUserType == accountInfo.userStatus.groupType">Notices</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item upgrade-link upgrade-account" href="/user/upgrade/" target="_blank" 
                    *ngIf="accountInfo.userStatus.currentPlan == '001'">Upgrade</a>
                <a class="dropdown-item" href="mailto:support@intouchid.net?Subject=Feedback%20on%20the%20new%20interface">Feedback</a>
                <a class="dropdown-item" href="/user/import/" target="_blank">Import data</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="/user/">Switch to old view</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="/logout/" 
                    (click)="utilsService.sendEvent('spreadsheet_view', 'logout_clicked', 'clicked on logout')">Logout</a>
            </div>
        </div>
    </div>
</nav>

And this is the script I am using to make a build: npm run cleanup && npm run ngc && webpack --config config/webpack.prod.js -p & my webpack config is: 这是我用来构建的脚本: npm run cleanup && npm run ngc && webpack --config config/webpack.prod.js -p &my webpack config是:

plugins: [
    new AotPlugin({
      tsConfigPath: './tsconfig.json',
      entryModule: helpers.root('src/app/app.module#AppModule')
    }),
    new webpack.LoaderOptionsPlugin({
      debug: true,  // config.debug has to be passed this way now too!
      htmlLoader: {
        minimize: false
      }
    }),
    new webpack.NoErrorsPlugin(),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
      mangle: {
        keep_fnames: true
      }
    }),
    new ExtractTextPlugin('[name].[hash].css'),
    new webpack.DefinePlugin({
      'process.env': {
        'ENV': JSON.stringify(ENV)
      }
    }),
    new CompressionPlugin()
  ]

There are implied end tags which are being implemented. 正在实施隐含的结束标记。 You can use less end tags. 您可以使用较少的结束标记。 Open up the console in your browser to see the error, it links this: https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags 在浏览器中打开控制台以查看错误,它链接到: https//www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags

I guess something with your quotes after interpolation or with non-printable characters. 我想插值后用引号或不可打印的字符。

Please check those lines : 请检查这些行:

<a class="dropdown-item" href="/user/notices/" target="_blank" *ngIf="accountInfo.userStatus.currentUserType == accountInfo.userStatus.groupType">Notices</a>
   <div class="dropdown-divider"></div>

and

<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/logout/" (click)="utilsService.sendEvent('spreadsheet_view', 'logout_clicked', 'clicked on logout')">Logout</a>

In my case the error was due to the minimization of HTML. 在我的情况下,错误是由于HTML的最小化。 Turning it off resolved the issue. 关闭它解决了这个问题。 To turn it off correctly please review the docs here: https://webpack.js.org/loaders/html-loader 要正确关闭它,请查看以下文档: https//webpack.js.org/loaders/html-loader

module: {
  rules: [{
    test: /\.html$/,
    use: [ {
      loader: 'html-loader',
      options: {
        minimize: false
      }
    }],
  }]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM