In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use element table components". In daily operation, I believe many people have doubts about how to use element table components. The editor consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about how to use element table components. Next, please follow the editor to study!
Let column = [
{label: "user id", prop: "userId"}
{label: "user name", prop: "userName"}
{label: "creation date", prop: "createData"}
]
Let data = [
{
UserId:1
UserName: Zhang San
CreateData:'2020-05-26 12 1015 56'
}
{
UserId:2
UserName: "Li Dog Egg"
CreateData:'2020-05-26 12 1015 56'
}
]
Let resolveColumn = _ cmptWidth (column,data)
Console.log (resolveColumn)
/ / [
/ / {label: "user id", prop: "userId", width: ""}
/ / {label: "user name", prop: "userName"}
/ / {label: "creation date", prop: "createData"}
/ /]
_ cmptWidth (min=30,column,data) {
/ / Field length container
Let temp= {}
/ / initialize the field length container based on the first row of data
Object.keys (data [0]) .forEach (key= > {
Temp [key] = []
})
/ / the field length of each row of data is stored in the field length container as 2 characters in Chinese and 1 in English.
Data.map (I = > {
Object.keys (I) .forEach (key= > {
Let str = I [key] & & I [key] .toString ()
Let cn = str & & str.match (/ [\\ u4e00 -\\ u9fa5] / g) & & str.match (/ [\\ u4e00 -\\ u9fa5] / g) .length | | 0
Let en = str & & str.match (/ [A-Za-z0-9] / g) & & str.match (/ [A-Za-z0-9] / g) .length | 0
Let len = Math.max (en + cn*2 +, 10)
Temp [key] .push (Math.min (len,min))
})
})
/ / return the column that adds the column width attribute
Return column.map (I = > {
Let width = Math.ceil (temp [i.prop] .reduce ((aforme b) = > aquib) / rows.length)
Return {
... i
Width:width*12+'px'
}
})
At this point, the study on "how to use element table components" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.