2017-04-14 80 views
4

當我在構建時,在觀看或運行服務器時它沒有提供任何內容,只是在構建時給出了這個奇怪的錯誤這個錯誤:Angular 4 Webpack 2&AOT:意外的結束標記「a」

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/[email protected]:192

這裏是我的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:[email protected]?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> 

這是我使用,使構建腳本:npm run cleanup && npm run ngc && webpack --config config/webpack.prod.js -p &我的WebPack配置爲:

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() 
    ] 
+0

'''標籤對應的是什麼?這是一個有效的HTML標籤嗎?編輯:另外,如果你改變''標籤的src'是靜態的,你有同樣的問題嗎? – Askanison4

+0

''是另一組分是改變'src'不利於 –

回答

0

我猜想你的引號插入後或與非打印字符的東西。

請檢查這些行:

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

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

我找不到引用的問題,因爲在我的整個項目中,我遵循相同的做法,但它給予錯誤只在這裏 –

+0

嘗試刪除上面一行中'target =「_ blank」'和'* ngIf ='之間的空格和換行符。我在http://jona.ca/blog/unclosed-tag-finder找到了只有一個空間的測試。然後你會在'(點擊)'行上出現同樣的問題'

+0

我編輯了我的答案,所以你應該把我的線貼在你的地方去測試 –