Tag Archives: ElementUI

[Solved] Vue router in the element UI navigation bar repeatedly clicks on the menu above version 3.0 and reports errors

Add the following code to the index.js file under the router folder:

import Router from 'vue-router'

// Solve the problem that vue-router in the navigation bar of ElementUI reports an error when repeatedly clicking the menu in version 3.0 or above

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

[Solved] cookie loss when uploading components using the elementui framework El upload

The background uses El upload to complete the upload. Sometimes it is found that the upload cannot succeed and will be redirected to the login page.

The check found that the URL request did not add a cookie request, and the cookie was missing, so the verification could not be completed.

The default request of El upload component is without cookie

Solution:
set the attribute with credentials to true. It supports sending cookie credential information (: with credentials =’true ‘)

If you follow the above method, the problem still exists, which may be caused by the existence of a virtual directory on your website.

The URL address assigned to the action of El upload must be the complete root directory path (/ virtual directory name/uploaded URL address)

It is emphasized here that the virtual directory name should be the same as the virtual directory name when you store cookies. It is recommended to keep the case consistent

      <el-upload
           class="upload-demo"
           ref="upload"
           :action="action_url"
           name="file"
           :with-credentials='true'
           :limit="1"
           :file-list="fileList"
           :auto-upload="false">
         <el-button size="small" type="primary">choose the files</el-button>
         <div slot="tip" class="el-upload__tip"></div>
      </el-upload>

Error in xxx.js from uglifyjs after elementui upgrade [How to Solve]

1. Error occurred while packaging and compiling

2. Solution

Reason: uglifyjs only supports Es5, and element UI may introduce some writing methods of ES6, resulting in webpack packaging failure.

Scheme: use bable to parse the element UI. To complete this operation, you only need to modify the build/webpack.base.conf.js file in the front-end folder, as follows:

// Before Modify
rules: [
    {
      test: /\.js$/,
      loader: 'babel-loader',
      include: [resolve('src'), resolve('test')]
    }
]
// 修改后
rules: [
    {
      test: /\.js$/,
      loader: 'babel-loader',
        include: [resolve('src'), resolve('test'), resolve('/node_modules/element-ui/src'), resolve('/node_modules/element-ui/packages')]
    }
]

It is equivalent to adding element UI to the package that needs Babel parsing. Then execute again npm run build  success.