Essay on Recording Questions (to be continued)

1. The array method accumulates var tasData=[1,2,3,4], eval(tasData.join("+")) No need to traverse, the fastest one.

2. The addition or multiplication of data in two arrays is realized by using the memory reference address, for example:

var arr1=[1,2,4]
var arr2=[3,5,7]
function(arr1,arr2){
     if (arr2.length == 0) {
      return arr1;
  } else {
      arr1.map((value,index)=>{
      arr2[index] *= value;
     })
 }

  console.log(arr2)

}

3. The initialization definition of the shuttle box el-transfer in Ele.me UI must be an array, otherwise the error e.splice is not a function will be reported.

4. Refresh the form el-table, you can add: key="mark3" to it, and write this.mark3+=1 where it needs to be refreshed

5. The data in the drop-down box is not displayed. Generally, this points to the problem. Look at the return value of axios to use the arrow function.

6. The attribute fixed:right in el-table will cause the table to be dislocated, so it is best not to use it.

7. When customizing in el-table needs to use loops, it is better to use template instead of dev, which will cause the first column of data in the table to run to the last column, which is very troublesome.

8. To intercept the last few items of an array, you can use length: var art=[1,2,4,6] directly art.length=2 to keep the first two items.

9. To intercept the last item of the string, directly use arr.split('=')[1] to indicate the value after = is intercepted.

10. Split an array into multiple arrays. example:

 var ketData=[1,2,3,4,5,6,7,8,9,10]
var newArray = [];
var index=0;
     while(index < ketData.length) {
        newArray.push(ketData.slice(index, index+=2));
}
onsole.log('newArray',newArray)

11. If the echarts chart finds that the data is refreshed, but the chart is not refreshed, please set var myChart = echarts.init(document.getElementById('areacc')); myChart.setOption(option,true); After setting true, the chart will be rebuilt .

12. Object.assign can assign the values ​​of all enumerable properties from one or more source objects to target objects For example:

const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };
const returnedTarget = Object.assign(target, source);

console.log(target);
// { a: 1, b: 4, c: 5 }

console.log(returnedTarget);
// { a: 1, b: 4, c: 5 }

13. [Important] Every time you encounter the content items in el-input or el-form after echoing or because other operations affect its own value, you cannot input or select, etc. This problem has been troubled for a long time, and the solution Yes: Rebind his form value For example: this.faaForm = JSON.parse(JSON.stringify(this.faaForm)) There is also a way to update a single value with this.$set method, for example: this.$set(this. faaForm, 'workbenchName', item.quotaName)

14. How to put a set of data into the value of multiple objects: for example:

var arr1=[1,2,3,4,5]
var arr2=[
  {name:11,value:''},
  {name:22,value:''},
  {name:33,value:''},
  {name:44,value:''},
  {name:55,value:''}
]

//把1,2,3按顺序放到下面的value 里

 arr2.forEach((item, index) => {
     item['value'] = arr1[index];
 })
console.log(arr2)

15. The method that needs to clear the verification in the el-form form must be placed in $nextTick (searchForm is the value bound to the form):

 this.$nextTick(() => {

          this.$refs.searchForm.resetFields()

    })

16. To loop the key and value of an object, you can use for in for example:

let obj = {         'a':'11',         'b':'22',         'c':'33',       }; for(let i in obj){     console.log(i); //abcd      console. log(obj[i]); // 11 22 33 } 17. Cancel the verification of the el-form form, falForm is the value of el-form ref="falForm ".




 




  this.$nextTick(() => {
       this.$refs.falForm.clearValidate()
  })

18. The el-table index will grow automatically (starting from 1), and will not be reset to 1 due to paging clicks.

 <el-table-column  type="index" label="序号"  :index="indexMethod" > </el-table-column>

// 索引分页自增累加, (当前页-1)*每页显示的条数+table的索引+1
indexMethod(index) {
    return (
        (this.currentPage - 1) * this.PageSize + index + 1
     ) 
},  

19. Records will appear on some vue pages, and the page is not loaded completely, resulting in variables such as {{name}}. Then the page disappears after rendering, how to solve this problem? Just add the v-cloak instruction to the outermost div, and then add it to the css:

[v-cloak]{ display: none;} 就行了。

v-cloak is a directive in the Vue.js framework to prevent uncompiled template content from being displayed until the Vue.js instance is mounted.

20. When using the el-dialog pop-up box in Ele.me UI, if you find that your pop-up box is always below the mask layer when you open it, remember to add the attribute: modal-append-to-body="false", Overlays must not be inserted over the body element. Otherwise, how to add z-index is useless (uncomfortable).  

To be continued, update any time you encounter problems. . .

Guess you like

Origin blog.csdn.net/qq_42174597/article/details/124732909