![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js-数据处理
储储随记
路漫漫其修远兮,吾将上下而求索。
展开
-
vue 类似tab标题滚动 标签左右滚动
在固定的宽度内,展示不固定标签列表,且每个标签的字数不确定<template> <div class="tag-box"> <div class="tag-list"> <ul ref="tagList" :style="{left: -nowLeft + 'px'}"> <li v-for="(item, index) in list" :key="index" :ref="'li'+ index">原创 2021-03-29 16:36:28 · 831 阅读 · 0 评论 -
数组、时间常用转化
数组-字符串,对象-字符串之间的转换const arr1 = ['春', '夏', '秋']arr1.push('冬') // 向数组插入数据 const obj = [{ id: 1 }, { id: 2, season: '夏天' }] obj[0].season = '春天' // 向对象中插入数据 const a1 = arr1.join(',') // 将数组转化成字符串 const a2 = a1.split(',') // 将字符串转化为数组 const o1 = JSO.原创 2021-03-03 15:27:47 · 277 阅读 · 0 评论 -
数组或数组对象-排序(js)
按照指定顺序排序created () { this.test()},methods: { test () { const arr = ['a', 'b', '秋', '夏', '冬', '春', 'c'] arr.sort(function (a, b) { var order = ['冬', '秋', '夏', '春'] // order是规则 return order.indexOf(b) - order.indexOf(.原创 2021-03-01 17:16:56 · 158 阅读 · 0 评论