-
In the chained promise function, how to determine which promise threw the error
I need to implement in a chained promise function, any function error in the middle terminates the program, and can catch the error function, and then perform different operations according to different error functions. How can the following code be imp...
-
React Project Cannot add property style, object is not extensible
import React from react ;
class PublicScreen extends React.Component {
constructor(props) {
super(props);
this.getStyle = this.getStyle.bind(this);
}
getStyle() {
const { width = 1920, height = 1080 } = this.pr...
-
Read a number, such as 521, change this number to 0521, and put it into four div, how to achieve?
read a number, such as 521
change this number to 0521
but put it into four div separately, how to realize it?
0 < div > 5 < div > 2 < div > 1 < div >
...
-
There are some questions about babel conversion for beginners of es6.
originally run directly in the browser (Chrome 65) will report ReferenceError errors, but after babel conversion, and then run, it will be undefined, these two errors are completely different, does it mean that the conversion of babel is not complete?
...
-
In the React project, a piece of code is optimized.
import React from react ;
import ReactDOM from react-dom ;
import . assets styles index.less ;
import Green from . assets images green.png ;
import Red from . assets images red.png ;
class Circle extends React.Component {
constructor...
-
The question about js this
function foo(){
setTimeout(()=>{
console.log("is:",this.id); 42
},100)
}
var id = 21;
foo.call({id:42})
The this of the function in js is dynamic, depending on who calls it at run time, in which the this inside foo points to an a...
-
How to use Generator to implement a chain dependent function?
how do I use generator to achieve the following functions?
function f1(){
return new Promise((resolve,reject) =>{
setTimeout(() =>{
resolve(1);
},1000)
})
}
function f2(valu...
-
How to pass parameters without anonymous functions in ES6 and not execute them immediately?
test(...arg) {
console.log("",arg);
}
render(){
return <View style={{flex:1,backgroundColor:"blue"}}>
<TouchableOpacity activeOpacity={1}
onPress={this. test("")}&...
-
In the React project, many import are used to insert pictures. How can this be simplified?
insert a large number of pictures into the project, how to simplify
import React from react ;
import ReactDOM from react-dom ;
import . assets styles index.less ;
import A0 from . assets images A0.png ;
import A1 from . assets images A1.p...
-
Parameter variables are declared by default, so you can't declare them again with let or const, but why can you declare them with var?
under normal circumstances, variables declared by let or const cannot be declared repeatedly, and an error will be reported even when using var. eg:
let a = 123;
var a = 456;
error prompt: Uncaught SyntaxError: Identifier a has already been declar...
-
This problem of js Arrow function
I don t understand why this is window in this broken code. Thank you for your understanding. Thank you.
var o = {
fn:() => {
console.log(this)
}
}
o.fn()
...
-
How do you use find in es6?
I want to return a data corresponding to id based on the data.id passed in
...
-
Es6 extension operator query
< H1 > Ruan Yifeng: the extension operator (spread) is three dots (.). It is like the inverse operation of rest parameters, converting an array into a sequence of parameters separated by commas. < H1 >
what does the inverse operation of rest parameter...
-
What is the understanding of es6's extension operator?
in es6. The extension operator expands the array
[1Magol 2pr 3] unfolds as 1Magol 2Jol 3, so what is this 1Magol 2Jol 3? An array is not an array, a string is not a string
later, there was also the operation of the object. The operator is called de...
-
In the React project, I want to be able to use div and canvas tags in {}, but this is not valid now
<div className={ break_down_div }>
{this.state.breakDown && this.state.breakDown.length != 0?
<canvas className={ blueCircle } >< canvas>
<div
re...
-
How does js implement a general regular validation form method (minimum code)
1. How to implement a general regular validation form with the least amount of code
= project, 1. Login has two input (verify mailbox, password 10 digits + letters)
2. input ()
both forms are displayed after input loses focus (correct or w...
-
Vue traverses the substitution array
first of all, there is such a piece of data
list[ zhangsan , lisi , wangmazi ]
people[
{
name: zhangsan ,
username:
},{
name: lisi ,
username:
},{
name: wangmazi ,
username:
}
]
then the qu...
-
Object.assign problem
looking at the Vue official website tutorial, there are the following suggestions for adding multiple attributes:
= split line = if you want to add new responsive attributes, don t be like this:
Object.assign ( vm.userProfile , { age: 27, favorit...
-
Axios cancels multiple repeat requests through cancelToken. Why does the last request take so long?
I have a vue project where ajax requests are sent using axios. one of the list pages, clicking on the list will send the details of the corresponding list of the request query. now in order to prevent frequent requests from being sent due to multiple ...
-
Why the module function in ES6 is first import and then from? Is there a smooth way to write?
< H2 > original question: < H2 >
A module that uses ES6 in a smart editor (such as WebStorm) introduces a module, first import {} from fs ; and then jump the cursor back to curly braces {} to write the desired module, because there is a smart ...