Tag Archives: javascript

[Solved] Jquery addclass reports an error under Firefox

There is no problem with the following code in Google browser and an error is reported in Firefox:

const doms = document.getElementsByClassName("cesium-baseLayerPicker-dropDown")
        for (let i in doms) {
            const dom = doms[i]
            if (dom) {
                $(dom).addClass("scroll-1")
            }
        }

The following modifications are required

 $(".cesium-baseLayerPicker-dropDown").addClass("scroll-1")

How to Solve Vue3 using deep syntax Error

For more information, please refer to my blog

Error reporting performance

Solution:

Adds the following configuration in .stylelintrc.js:

/**
 * @module .stylelintrc
 * @author: huoyou
 * @description: css
 */
module.exports = {
  rules: {
    ...
    'selector-pseudo-class-no-unknown': [
      true,
      {
        ignorePseudoClasses: ['deep']
      }
    ],
    ...
  }
};

Yarn vue3 modify the name of the source file Error [Solved]

ERROR Failed to compile with 1 error PM 6:26:46
This relative module was not found:
* ./RoleFormDialog in ./node_modules/cache-loader/dist/cjs.js??ref–13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref–1-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref–1-1!./src/views/Role/List.vue?vue&type=script&lang=js

Solution:
Also change the directory where the source file is located to any other name (here it is changing Role to RoleAAA) and then change back to the original name (here it is changing back to Role), yarn will automatically clear the cache and the problem is solved.

 

[Solved] Vue binding dynamic inline style Error: transform:rotate()

reason:

V-bind or ‘:’ is followed by the written JS code, which is written in the form of key value pairs. The key is the CSS style attribute name of the tag, and the key is the attribute value. The key value must be a string or a variable (provided that the variable must be declared in the data first): style = “{transform: rotate()}” this writing browser calls rotate as a function rotate(), so an error will be reported

Solution:

//String mode
:style="{transform: 'rotate(60deg)'} 
//Variable form
:style="{transform: `rotate(${Variable}deg)`}

[Solved] QuotaExceededError the quota has been exceeded — Firefox

QuotaExceededError the quota has been exceeded — Firefox
Firefox Error:

QuotaExceededError the quota has been exceeded

1. Enter about:config in the Firefox address bar

2. Search DOM.storage.default.Quto in the advanced settings interface.

3. Set its value to 102400 or greater.

 

Solution:

rewrite the method of Localstorage (getitem, setitem, removeitem…)
the following record can be written:

function getStorage() {

    var storageImpl;

     try { 
        localStorage.setItem("storage", ""); 
        localStorage.removeItem("storage");
        storageImpl = localStorage;
     }
     catch (err) { 
         storageImpl = new LocalStorageAlternative();
     }

    return storageImpl;

}

function LocalStorageAlternative() {

    var structureLocalStorage = {};

    this.setItem = function (key, value) {
        structureLocalStorage[key] = value;
    }

    this.getItem = function (key) {
        if(typeof structureLocalStorage[key] != 'undefined' ) {
            return structureLocalStorage[key];
        }
        else {
            return null;
        }
    }

    this.removeItem = function (key) {
        structureLocalStorage[key] = undefined;
    }
}

cusSto = getStorage();

Vue Package Image Error: Syntax Error: Error: ‘**\node_modules\pngquant-bin\vendor\pngquant.exe‘

When packaging, an error is displayed at a picture path
Syntax Error: Error: ‘D:\work\tiny-sample\src\frontend\web\packages\src-entry\node_modules\pngquant-bin\vendor\pngquant.exe’

It can be seen that the package pngquant-bin reports an error, and the package is derived from the dependency of image-webpack-loader, so the root cause is image-webpack-loader.
Solution: delete the dependency image-webpack-loader, and then reinstall it. If it doesn’t work, try a few more times.

npm uninstall image-webpack-loader
npm install image-webpack-loader

If it still fails, set the image for NPM and repeat the above two steps

[Solved] electron-builder Package mac Error: panic: runtime error: index out of range

An error is reported in the packaging mac of electron builder. The detailed error information is as follows:

goroutine 1 [running]:
github.com/develar/app-builder/pkg/icons.ConvertIcnsToPng(0xc0000ca630, 0x2d, 0x7ffd9f40874a, 0x2e, 0x2, 0x2, 0xc0000ca630, 0x2d, 0xe53320)
	/Volumes/data/Documents/app-builder/pkg/icons/icns-to-png.go:60 +0x4ab
github.com/develar/app-builder/pkg/icons.doConvertIcon(0xc00012a400, 0x5, 0x8, 0xc00025ec20, 0x2, 0x2, 0x7ffd9f4086ec, 0x3, 0x7ffd9f40874a, 0x2e, ...)
	/Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:226 +0xa0d
github.com/develar/app-builder/pkg/icons.ConvertIcon(0xc0000ad3c0, 0x97, 0x0, 0xf6400f7800000000)
	/Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:56 +0xd6
github.com/develar/app-builder/pkg/icons.ConfigureCommand.func1(0xc0002375f0, 0x40b705, 0xc2b0e0)
	/Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:33 +0x7f
github.com/alecthomas/kingpin.(*actionMixin).applyActions(0xc000124d98, 0xc0002375f0, 0x0, 0x0)
	/Volumes/data/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/actions.go:28 +0x6d
github.com/alecthomas/kingpin.(*Application).applyActions(0xc0000e8780, 0xc0002375f0, 0x0, 0x0)
	/Volumes/data/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:557 +0xdc
github.com/alecthomas/kingpin.(*Application).execute(0xc0000e8780, 0xc0002375f0, 0xc00021b150, 0x1, 0x1, 0x0, 0x0, 0x0, 0x904545)
	/Volumes/data/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:390 +0x90
github.com/alecthomas/kingpin.(*Application).Parse(0xc0000e8780, 0xc0000ae010, 0xf, 0xf, 0xc0000e8780, 0xc00008a058, 0x0, 0x0)
	/Volumes/data/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:222 +0x213

Solution:
put 512×512 in the icons directory of the icon Png icon to complete packaging
for example:
dist/icons/512x512.png

After Vue is packaged to the server, the static resource path reports an error

The error reporting path is:
http: domain name/CSS/XX css

In fact, it should be:
http: domain name/dist/CSS/XX/CSS

Method:
ensure that the value of publicpath is: publicpath: ‘. /’

ps:config.js or Vue-config.js file, according to the actual situation, if the editor cannot be found, search publicpath globally

Vue3 Error: [vue/no-multiple-template-root] The template root requires exactly one element

vue3.0 supports <template/></template> tag to delegate more than one root element
Building the project with the latest Vite, the code in the default app.vue is as follows:

The code can run normally, but the vscode gives an error prompt:

[vue/no-multiple-template-root]
The template root requires exactly one element. eslint-plugin-vue

The reason is that the vetur plug-in has not been updated

The temporary solution is

Settings -> Search: eslint plugin Vue -> Uncheck the first (Vetur › Validation: Template )

[Solved] Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs extension

In the process of learning ES6, an error is reported when and running JavaScript files, which is reproduced in detail

1. Create a new file, add test es, and use idea to open the folder
2. Add package.json file: NPM init – y
3. Create a new test.js file in the folder test-es, the contents of which are as follows

let a = 1111
let b = 2222
var c = function(){
	console.log(3333)
}
function ddd(){
	console.log(4444)
}
function eeeeee5(){
	console.log(555)
}
export {
	a,
	b,
 	c,
    ddd,
	eeeeee5 as eee, //The way to rename: name eeeeeeee as eee, you can output the same variable or method with different names
	eeeeee5 as e5 // rename the way: name eeeeee as eee, you can output the same variable or method with a different name
}

4. Right click and click Run ‘test.JS’, the error is reported as follows:

Solution:

According to the error message, in package JSON add “type”: “module”, and then run test.JS file, no error will be reported