Tag Archives: View.js

[Solved] ✖ 2 problem (1 error, 0 warnings) 2 error and 0 warnings potentially fixable with the`–fix`

Semi in eslint is to check whether the semicolon is wrong. No trailing spaces is the absence of spaces in the code Open. Eslintrc.js in the project and add the following code in the rules to solve the above problems. Just add the first and second lines of code in the box. Some are added to the problems later. It is recommended to add them because they are useful later.

'space-before-function-paren': 0,
'semi': 'off',
'quotes' : 'off',
'comma-dangle' : 'off',
'vue/comment-directive': 'off'

Eslint requires strict code format. Sometimes errors will occur when there are fewer or more spaces. It is recommended to replace the extensions in. Eslintrc.js in the project  ‘@ Vue/standard ‘is commented out. This will reduce many subsequent format problems.

CORS error has been blocked by CORS policy [How to Solve]

Problem description

The global request is intercepted through the axis of Vue. After adding the identify and token fields to the request header, the back-end zuul gateway is accessed. An error occurs in the browser, resulting in that the background cannot receive the custom header field of HTTP package and cannot authenticate the gateway well
the error is as follows:
access to XMLHttpRequest at‘ http://127.0.0.1:27000/api/v1/index -Infos’ from origin ‘http://’ has been blocked by CORS policy: request header field identification is not allowed by access control allow headers in preflight response.
network and console errors are as follows:

Error analysis

The background is cross-domain. An error occurs when a field is added to the header. In CORS, the options method will be used to initiate a pre-check request (generally, it will be automatically initiated when browsing detects that the request is cross-domain) to detect whether the actual request can be accepted by the server. The access control request method header field in the pre-check request message informs the server of the HTTP method used for the actual request
the access control request headers header field tells the server the custom header field carried by the actual request. The server determines whether to accept the next actual request based on the information obtained from the pre-check request. The access control allow methods header field returned by the server informs the client of all allowed request methods
to sum up, when the browser sends a request header with customization, the browser will first send an options pre-check request to the server to detect whether the server of the request allows customization of cross-domain fields. If yes, continue to execute the request. If not, an error message will be returned to prompt an error.

Solution:

Add the corresponding allow field in the cross domain request header and add your own custom field in the access control allow headers field. The request can be accessed. The interception code in zuul:

@Override
    public Object run() throws ZuulException {
        RequestContext ctx = RequestContext.getCurrentContext();
        HttpServletRequest request = ctx.getRequest();
        HttpServletResponse response = ctx.getResponse();

        response.setHeader("Access-Control-Allow-Origin",request.getHeader("Origin"));
        response.setHeader("Access-Control-Allow-Credentials","true");
        response.setHeader("Access-Control-Allow-Methods","GET, HEAD, POST, PUT, DELETE, OPTIONS, PATCH");
        response.setHeader("Access-Control-Allow-Headers","authorization, content-type,token,identify");
        response.setHeader("Access-Control-Expose-Headers","X-forwared-port, X-forwarded-host");
        response.setHeader("Vary","Origin,Access-Control-Request-Method,Access-Control-Request-Headers");

        if ("OPTIONS".equalsIgnoreCase(request.getMethod())){
            ctx.setSendZuulResponse(false); 
            ctx.setResponseStatusCode(HttpStatus.OK.value());
            ctx.set("isSuccess", true);
            return null;
        }
        ctx.setSendZuulResponse(true); 
        ctx.setResponseStatusCode(HttpStatus.OK.value());
        ctx.set("isSuccess", true);
        return null;
    }

Error: Projects must list all files or use an ‘include‘ pattern.

When importing a file, the file clearly exists but an error is reported:

File 'xxx/packages/@vue/src/use-list.ts' is not listed within the file list of project 'xxx/packages@/vue/tsconfig.json'. Projects must list all files or use an 'include' pattern.

resolvent:

  stay   Is not listed within the file to add or modify a regular path to the include in the file indicated.

At present, the file indicating the path regularity problem is tsconfig.json, so go to the tsconfig.json file to view the include item.

tsconfig.json:

{
  "include": ["src"],
}

Modified tsconfig.json:

{
  "include": ["src/**/*.ts"],
}

INFO Starting development server…. ERROR Error: Rule can only have one resource source (provided

Problem
when writing a Vue cli project, the following problems occurred when running NPM run serve

after consulting the data, you know that you have installed the latest version of SASS loader, which may be because the version is too new, Incompatible with project plug-ins or dependencies

solution
Enter
in the terminal, delete the newer version NPM uninstall sass loader
install the lower version NPM install sass- [email protected] –save-dev

Solution to Vue cli · failed to download repo vuejs templates/webpack: connect etimeout followed by an IP digital error message

Vue scaffold construction error: Vue cli · failed to download repo vuejs templates/webpack: connect etimeout followed by an IP number,
in fact, it is a prompt for connection timeout. It should be that you need to climb over the wall when downloading a package, resulting in connection timeout. The screenshot of timeout error is as follows:

so we changed to offline GitHub, which is too difficult to open. Go here
1: https://codechina.csdn.net/mirrors/vuejs-templates/webpack?utm_ source=csdn_ github_ After downloading the accelerator, unzip it, and then change the name to webpack

2: Find. Vue templates in C: \ users \ administrator or ThinkPad in the user of drive C. if not, shift + right-click (or just right-click) MD. Vue templates to create a new one, and then put the webpack in it;

3: Go to your own project and right-click (or just right-click) Vue init webpack again. Project file name — offline; (parameter required – offline indicates offline initialization)

Vue Project Error: Expected indentation of 2 spaces but found 4,Newline required at end of file but not found

Several error messages were encountered when learning Vue project was packaged

★   Extra semicolon

The first is that there is an additional semicolon. The error query found that main.js does have a semicolon. After we deleted it, the error disappeared

★   Expected indentation of 2 spaces but found 4

The second one is “expected to indent 2 spaces, but found 4”. After Baidu search, it is found that this is not an error, but a check rule. Find this file in the project and add this configuration. See the figure below

★   Newline required at end of file but not found

The third one is more wonderful. It means that “line breaks are required at the end of the file, but they are not found”. Then we go to the error file, that is, main.js. We can solve the error by typing enter at the end. See the figure below

Adding a blank line here can solve the problem of error reporting

Uniapp uses CMD to import uview. An error is reported, and the file search fails: ‘uview UI’‘

Uniapp uses CMD to import uview. An error is reported, and the file search fails: ‘uview UI’

Note: do not use CMD to import uview plug-in. If you use local file import, the problem does not exist and can be imported normally.

1.App.vue

2.main.js

3.pages.json

4.uni.scss

5. Uview is imported into the project root directory

Vue project, browser error: referenceerror: H is not defined

JSX syntax
encounters this error: check whether there are parameters similar to the code structure in the picture in your data() {
}. This belongs to JSX syntax and can also render components directly. However, in some specific scenarios, the browser console will report
referenceerror: H is not defined. This error
solution: create a new method in methods () {} and clip the parameters of the whole structure above to the method. The parameters in the data that you called before the template code block is changed from calling the methods to solving the problem from the method,

How to Solve Nodejs error: cannot find module ‘. /application’

Open the terminal and enter nodemon./index.js. The following error messages appear:

Solution:

After entering the directory where index.js is located
delete node_ Module folder and package lock.json file open the terminal, type NPM clean cache , clear the cache, type NPM I , and type nodemon index. JS  for installation dependency
Run nodemon./index.js again

Perfect solution~