We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<template> <div> <div class="img"></div> <p></p> </div> </template> <style> .img { width: 100px; height: 100px; float: left; background: red; } p { background: bisque; width: calc(100% - 100px); height: 100px; margin-left: 100px; } </style>
const ajax = console.log // 请给出代码 const request = requestPool(3) request.start()
题解
const ajax = console.log const urls = ['1', '2', '3'] function requestPool(val) { let pool = []; let urls = val function execTask() { if(urls.length) return const url = urls.pop(); const task = ajax(url) pool.push(task) task.then(res => { const index = pool.findIndex(item => item === task); pool.splice(index, 1); }) } function loopTask(race) { if(!race) return race.then(res => { execTask() const race = Promise.race(pool) loopTask(race) }) } return { start(num) { let max = num; while(pool.length < max) { execTask() } const race = Promise.race(pool) loopTask(race) } } } const request = requestPool(urls) request.start(3)
typeof null: 'object' typeof 'object': 'string'
1. Array.isArray 2. xxx instanceof Array // true 3. Object.prototype.toString.call(xxx) // [object Array] 4. xxx.constructor == Array // true
// 解法1 const str = 'you_code'; let [left, right] = str.split('_') right = right[0].toUpperCase() + right.slice(1); console.log(`${left}${right}`) // 解法2 const str = 'you_code'; str.replace(/_(.?)/, ($1) => { return $1.slice(1).toUpperCase() })
伪代码
const checkboxGroup = { template: ` <checkbox-group></checkbox-group> `, props: { id, defaultVal, options }, data: { type, size, checked, disabled, map }, methods: { addEventListener() { $on('broadcast', (id, value) => { map[id] = value this.check() }) }, check() { let isAllChecked = true Object.keys(map).forEach(key => { if(!map[key]) { isAllChecked = false } }) return this.checkedAll = isAllChecked } }, } const checkbox = { template: ` <checkbox></checkbox> `, props: { id, type, size, disabled, checked }, data: { value }, methods: { onChange() { if(this.disabled) return this.value = !this.value; $emit('broadcast', this.id, this.value) $emit('change', this.value) } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1. 设计一个左边是img元素,右边是一个内容无限多的p元素,要求p元素随父元素的宽度自适应
2. 设计一个并发数为n的请求器
题解
typeof typeof null 值是多少
题解
如何判断数组类型
给定下划线命名的字符串,要求转换为驼峰法格式,提供多种解法
题解
实现一个checkbox组件,和一个全选框,要求两个组件保持联动,请说明设计思路
伪代码
The text was updated successfully, but these errors were encountered: