Tag Archives: front end

Error creating webgl context [How to Solve]

Error creating webgl context

This error is a webgl context error. There is a stupid way to use it for the time being:

chrome://flags/#ignore-gpu-blacklist

Open the address in the browser, search webgl, change the items of enablers display component to use a new GPU thread to default, and then click relax in the lower right corner

[Solved] Vue Compile Error: JavaScript heap out of memory

Vue element UI project

The default size limit of V8 engine for memory use is 1.4g. You can set the limit through the node.js command to solve this problem. Modify the contents in the package.json file as follows.

"serve": "npx --max_old_space_size=4096 vue-cli-service serve",
"build": "npx --max_old_space_size=4096 vue-cli-service build --modern"

General Vue items

Vue didn’t put  package.json   inside  scripts  The node command of the script command of the field is hidden. We directly write the option parameters provided in V8 above to scripts  Field  node  After the command, it’s OK. An example is as follows

"build": "node --max_old_space_size=4096 build/build.js"

How to Solve Vue loading 3D model Error

Loading the 3D model in vue today keeps reporting errors

There is no error in the code, but the path of the model is wrong, resulting in an error when loading the model (the model was originally placed under the assets path and imported through the relative path). After checking the data, it is found that the model file cannot be placed under the assets path, but under the public path, and the file under the public must be imported through the absolute path (this depends on the configuration of publicpath in vue.config.js. The default is /)

Specific code and steps for loading 3D model in Vue:

1. NPM install three — save package for installing three.js

2. Introduce three related packages

import * as THREE from 'three';
import {OrbitControls} from 'three/examples/jsm/controls/OrbitControls';
import {MTLLoader} from 'three/examples/jsm/loaders/MTLLoader';
import {OBJLoader} from 'three/examples/jsm/loaders/OBJLoader';

3. The model should be placed in the public folder. The resources placed in the public directory will be copied directly and will not be packaged by webpack

4. Load model

Vue Start Error: This relative module was not found:

This relative module was not found:
I checked it for a long time and found nothing wrong. Finally, I took a look at the directory

I first created an empty project… And then created another project in the empty project by using the terminal command NPM create. The result is that when NPM install XXX is followed, it is in the parent directory of vuero. Therefore, an error will be reported when starting vuero,
in addition, try to use cnpm install XXX instead of NPM insatl XXX

Ie11 reports an error unhandled promise rejection typeerror: the object does not support

The problem of ie11 is the biggest problem. At this time, you should check the most likely place of the problem step by step
I make this error because I use the following code when making type judgment:
toString. Call (svalue)==‘ [object date] ‘
such a writing method is not recognized in ie, and an unhandled promise rejection typeerror will be reported: the object does not support it, so it is necessary to change the writing method

Object.prototype.toString.call(sValue) !== ‘ [object date] ‘
this way of writing is recognized by ie

The Vue parent component uses ref to call the sub component method and reports an error

In the Vue project, the parent component uses $ref to call the method of the child component to report an error. At first, the console will report an error. When the pop-up window is closed and the page is not refreshed, the solution is simple and crude~

Both methods are OK, but the second is more intuitive optimization.

The first method uses a timer to solve the problem that the method is not loaded because the sub components are not mounted when the ref attribute is initially rendered. At this time, this method does not exist, so it cannot be accessed. Add a timer to delay execution. However, if the data is displayed one second later, you will directly see the loading problem of this page;

Therefore, the second method is more appropriate to solve the problem that DOM elements are not loaded. Let the method wait

Vant weapp uses the dialog pop-up box to prompt for path error

When writing wechat applet, use the dialog pop-up box of the third-party vant web to prompt the path error

But it is used according to the official tips

  After repeated modification, the path still reports an error. According to the hierarchy, the path is no problem

 

  The problem of path error will still be reported!

  Finally, after repeated attempts, the package/dist needs to be removed and can be used normally

 

[Solved] Vue item error: Regeneratorruntime is not defined

Project scenario:

The company’s official website project built with Vue scaffold


Problem Description:

async/await is used when processing asynchrony. It is found that the console reports an error regeneratorruntime is not defined


Cause analysis:

The project uses Babel, and Babel needs some auxiliary functions when translating ES6 syntax. When there is no module to encapsulate these auxiliary functions, it will report similar not defined.

Regeneratorruntime is an auxiliary function generated by Babel for async/await compatible syntax. Regenerator runtime is not defined. Obviously, the package of regenerator runtime is missing.


Solution:

    1. install transform runtime
yarn add  @babel/plugin-transform-runtime -D

Configure Babel (I use Babel 7.0 as Babel.Config.JS)

plugins: [
    
    [
      "@babel/plugin-transform-runtime"
    ]
    
  ]

Restart the service and find that there is no error when running

[Solved] Uncaught (in promise) TypeError: XXX.a is not a constructor

Tips:

Solution:

Step 1:

npm add vue-grid- [email protected] -beta1

Step 2:
Import vuegridlayout from ‘Vue grid layout’ in
mian.js

Add: .use (vuegridlayout)
createapp (APP).use (Axios).use (router).use (vuegridlayout).mount (‘#app’)

Because Vue grid layout is vue2, but you use vue3, you need to install the dependencies and related configurations of vue3

[Vue warn]: Error in render: “TypeError: Cannot read properties of undefined

   [Vue warn]: Error in render: "TypeError: Cannot read properties of undefined

Cause: rendering error:

Conclusion: in the expression A.B.C, if there is no object B in object a, then reading the value in object A.B.C will naturally report an error. If it is a two-level expression A.B, no error will be reported and undefined will be returned, The third floor will report an error

Solution:


    <!-- Use the error report directly -->
    {{sku[0].skuName}}

    <!--  Solution  -->
    <template v-if="sku[0]"> {{sku[0].skuName}}</template>

Error in v-on handler (Promise/async): “[object Object]“

Put the request processing in main.js:

axios.interceptors.response.use(
  response => {
    if (response.data.code != 0) {
      return Promise.reject(response);
    }
    return response.data
  }
)

It is found that when the code returned by the back end is not zero, that is, when return promise.rehect (response) is executed, although the code runs normally, the console will report an error:

vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in v-on handler (Promise/async): "[object Object]"

found in

---> <Login> at src/views/Login.vue
       <App> at src/App.vue
         <Root>

Find the problem on the Internet and find that the exception of promise.rehect (response) needs to be captured, but most of them are captured in the component. Isn’t it meaningless to put the judgment in the main file, so you can put the capture processing in the main file, as follows:


axios.interceptors.response.use(
  response => {
    if (response.data.code != 0) {
      Message({content: response.data.message});
      return Promise.reject(response).catch(()=>{});
    }
    return response.data
  },
 )

That is, add . Catch (() = & gt; {}) directly after promise. Rehect (response) , which is currently valid for personal testing.