Tag Archives: front end

[Solved] Vue prettier error: error Delete `␍` prettier/prettier

The console error message is as follows

F:\aaaaa\dice-front\store\tag.js
  1:30  error  Delete `␍`  prettier/prettier
  2:11  error  Delete `␍`  prettier/prettier
  3:3   error  Delete `␍`  prettier/prettier
  4:1   error  Delete `␍`  prettier/prettier
  5:27  error  Delete `␍`  prettier/prettier

Solution 1: automatically identify the end

Add this to the first set in the project .pretierrc file.

"endOfLine": "auto"

Solution 2:

In the project In the .editorconfig file, Change end_of_line to CRLF. (used globally if possible)

Reason: git ends with CRLF and LF on different computers

The newline characters of text files under windows and Linux are inconsistent.

During line feed
windows uses both carriage return character Cr (carriage return character) and line feed character LF (linefeed character)
Mac and Linux systems only use the line feed LF
the old MAC system used the carriage return CR.

[Vue warn]: Error in mounted hook: “Error: please transfer a valid prop path to form item“

Problem generation

I encountered some problems when writing the project. Although it has little impact on the project, a red report looks uncomfortable, so I’ll see how to solve it and report the following errors

[Vue warn]: Error in mounted hook: “Error: please transfer a valid prop path to form item!”

English:
[Vue warning]: mounting hook error: “error: please pass a valid prop path to form an item!”

Causes of problems

In the Chinese translation, we can clearly know that there is an error in the mounting hook, that is, the value of prop is wrong

Solution:

Modify :prop = "'domains.'+ index +'.value '" to :prop = "domain.fieldname"

<a-form-model-item
  v-for="(domain, index) in model.configDetails"
  :key="index"
  :label="index === 0 ?'Add field' : ''"
  :prop="'domains.' + index + '.value'"
  :rules="{
    required: true,
    message: 'Can not be empty!',
    trigger: 'blur',
  }"
>
  <a-input v-model="domain.fieldName" placeholder="Enter field name" style="width: 40%; margin-right: 8px" />
  ~
  <a-input v-model="domain.fieldValue" placeholder="Enter field value" style="width: 40%; margin-right: 8px" />
  <a-button v-if="model.configDetails.length >= 1" @click="removeDomain(domain)">删除</a-button>
</a-form-model-item>

After modification

<a-form-model-item
  v-for="(domain, index) in model.configDetails"
  :key="index"
  :label="index === 0 ?'Add field' : ''"
  :prop="domain.fieldName"
  :rules="{
    required: true,
    message: 'Can not be empty!',
    trigger: 'blur',
  }"
>
  <a-input v-model="domain.fieldName" placeholder="Enter field name" style="width: 40%; margin-right: 8px" />
  ~
  <a-input v-model="domain.fieldValue" placeholder="Enter field value" style="width: 40%; margin-right: 8px" />
  <a-button v-if="model.configDetails.length >= 1" @click="removeDomain(domain)">删除</a-button>
</a-form-model-item>

Expand

When the form is verified, prop specifies that the attribute to be verified must be the attribute name of the corresponding object in the form model attribute

[Solved] Error: Cannot find module ‘@/views/xxx‘ at webpackEmptyContext

When you clone a Vue project from the open source platform, it is reported that the corresponding module cannot be found after logging in.

After searching a lot, it was finally solved.

export const loadView = (view) => {
  return () => import(`@/views/${view}`)
}

Change to the following

export const loadView = (view) => {
  return (resolve) => require([`@/views/${view}`], resolve)
}

It can be solved.

Cause: there is a problem with the webpack version. Dynamic import in webpack 4 does not support variable mode

The project can be seen in the elephant template.

[Solved] Error: ENOSPC: System limit for number of file watchers reached

Project environment

Vue project

Cause of problem

The number of file monitoring is too large and the system limits it

Modify {etc/sysctl.d

 fs.inotify.max_user_watches = 524288

Apply changes

sudo sysctl -p --system

Docker inherits some setting files on the host. In order to prevent global impact, the above files will be set to read only in docker. Therefore, you need to change the above configuration on the host. After the host changes, docker automatically inherits.

How to Solve electron import page Error

Uncaught ReferenceError: require is not defined
at index. js:1

index. Index. HTML file js

The following is index.js file

index.JS error

You need to add the following code in the created window: see the first figure for details

 webPreferences: {
    webSecurity: false, // Cancel cross-domain
    nodeIntegration: true, // v5 version requires this line
    contextIsolation: false, // v12 version needs to add this line
    enableRemoteModule:true // v10 version Turn on remote module
}

How to Solve Webpack packag iconfont font error

ERROR in ./src/fontsize/iconfont.css 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> @font-face {
|   font-family: "iconfont"; /* Project id 2969850 */
|   src: url('iconfont.woff2?t=1638862344321') format('woff2'),
 @ ./src/index.js 2:0-32

 

 

Solution: The webpack.config.js file is wrong, the configuration file should be

[Solved] react-router-dom Error: index.js:1 Warning: Functions are not valid as a React child.

index. js:1 Warning: Functions are not valid as a React child. This may happen if you return a Component instead of < Component /> from render. Or maybe you meant to call this function rather than return it.

reason:

1. When you return a component, you mistakenly write it as component instead of <Component/>

2. Maybe you want to call this function instead of return it.

For example:

① When calling a method, forget to add the following parentheses.

② When using react-router version 6.0.2 (released in 20211110), the writing method has been changed when registering the route.