我想把div放在里面垂直居中col-md-12.这是结构:
.list-item {
border-bottom: 1px solid #e7e7e7;
float: left;
padding: 15px 0;
width: 100%;
}
.list-item img {
width: 60px;
height: 60px;
}
.col-md-2 {
float: left;
width: 16.66666667%;
}Run Code Online (Sandbox Code Playgroud)
<div class="list-item col-md-12 clearfix">
<div class="col-md-1">
<img class="img-circle" src="https://aframe.io/aframe/examples/_skies/puydesancy.jpg">
</div>
<div class="col-md-2">
<strong>
<a href="#/buildings/1">Central park</a>
</strong>
</div>
<div class="col-md-5">
<span>The description for central park description for the central park</span>
</div>
<div class="col-md-2">
<span>Category count:</span>
<strong>3</strong>
</div>
<div class="col-md-2">
<span>Panorama count:</span>
<strong>7</strong>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
我想:vertical-align: middle和 …
我while以这种方式使用:
while (value < -180 || value > 180) {
if (value < -180) {
value += 360
}
if (value > 180) {
value -= 360
}
}
Run Code Online (Sandbox Code Playgroud)
不过,我想使用递归函数而不是while. 我在谷歌上搜索但找不到任何东西。所以我想也许我可以在这里得到答案。
我正在使用无头 Chrome 包Puppeteer运行测试:
const puppeteer = require('puppeteer')
;(async() => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://google.com', {waitUntil: 'networkidle'})
// Type our query into the search bar
await page.type('puppeteer')
await page.click('input[type="submit"]')
// Wait for the results to show up
await page.waitForSelector('h3 a')
// Extract the results from the page
const links = await page.evaluate(() => {
const anchors = Array.from(document.querySelectorAll('h3 a'))
return anchors.map(anchor => anchor.textContent)
})
console.log(links.join('\n'))
browser.close()
})()
Run Code Online (Sandbox Code Playgroud)
我正在运行脚本:node --harmony test/e2e/puppeteer/index.js …
当我这样做时new Date():
Thu Dec 28 2017 10:17:58 GMT+0800 (??????)
Run Code Online (Sandbox Code Playgroud)
如果我.valueOf()在那个日期申请,我会得到:
1514427724039
Run Code Online (Sandbox Code Playgroud)
这就是我想要的。
现在,我需要应用.valueOf()到这样的日期:2017/12/28。我尝试使用Luxon转换日期(因为应用于.valueOf()YYYY/MM/DD 不会产生数字):
DateTime.fromISO(startDate.replace(/\//g, '-')).toRFC2822()
// => Thu, 28 Dec 2017 00:00:00 +0800
Run Code Online (Sandbox Code Playgroud)
但是,应用valueOf()该结果会返回相同的字符串。不是第一个例子中的数字。
我应该怎么做才能从中产生一个数值YYYY/MM/DD?只是我做了DDD MMM DD YYYY GMT+0800 (X country standard time)?
以下代码检查字段是否为文件类型以及其中是否存在实际文件。如果是这种情况,请上传照片并更新建筑物。如果情况并非如此,请使用旧照片更新建筑物:
fields.forEach(field => {
building[field.name] = field.value || this.building[field.name]
if (field.type === 'file' && !util.isEmpty(field.photo.file)) {
api.uploadPhoto(field.photo.file).then(resp => {
building[field.name] = resp
this.updateBuilding(building)
})
} else {
building.logo = this.building.logo // to prevent updating logo
building.floorplan = this.building.floorplan // to prevent updating logo
this.updateBuilding(building)
}
})
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但由于this.updateBuilding(building)它是在一个循环中,所以它被称为倍数。
如何做到这一点,以便仅在最后一次迭代中调用?
这是代码(Vuex变异):
export const CREATE_PANORAMAS = (state, panoramas) => {
console.log('building.panoramas:', state.building.panoramas)
console.log('panoramas:', panoramas)
state.building.panoramas.concat(panoramas)
console.log('result:', state.building.panoramas)
}
Run Code Online (Sandbox Code Playgroud)
这是各自日志的结果:
[] // building.panoramas
[{ name: "", objectId: "5849133aac502e006c581b58" }] // panoramas
[] // result
Run Code Online (Sandbox Code Playgroud)
为什么两个数组不连接?
我正在创建具有排序功能的基本表:
<template>
<!-- more code -->
<tr v-for="item in sortBy(data.body, { name: 'name', order: 1 })">
<td v-for="field in item">{{ field }}</td>
</tr>
<!-- data.body => [{ name: Group 1 }, { name: Group2 }, // etc.] -->
</template>
props: {
data: {
type: Object,
default () {
return {}
}
}
},
methods: {
sortBy (data, params) {
// the warning disappears if I only leave "return data"
data.sort((a, b) => {
return a[params.name] - b[params.name] * params.order
}) …Run Code Online (Sandbox Code Playgroud) const dt = DateTime.fromISO(new Date(date))
// dt => DateTime {ts: 1516876197386, zone: LocalZone, loc: Locale, invalid: "unparsable", weekData: null, …}
return dt.toFormat('yyyy/mm/dd')
Run Code Online (Sandbox Code Playgroud)
结果是:Invalid DateTime。为什么会这样以及如何解决?
Luxon的文档:https ://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html#instance-method-toFormat
我有这样的数据:
{
"-L8BpxbS70KYrZMQUF0W": {
"createdAt": "2018-03-22T16:33:57+08:00",
"email": "ss@ss.ss",
"name": "ss"
},
"-KYrZMQUF0WL8BpxbS70": {
// etc.
}
}
Run Code Online (Sandbox Code Playgroud)
我想转变成这个:
[{
id: '-L8BpxbS70KYrZMQUF0W
createdAt: "2018-03-22T16:33:57+08:00",
email: "ss@ss.ss",
name: "ss"
}, {
id: -KYrZMQUF0WL8BpxbS70"
// etc.
}]
Run Code Online (Sandbox Code Playgroud)
我从这开始:
Object.keys(idBasedObjects).forEach(key => {
console.log(resp[key])
})
Run Code Online (Sandbox Code Playgroud)
但我明白了undefined.
创建这个数组的最佳方法是什么?
我有一个帮助器,只是抛出一个错误:
export const checkPanoramaFormat = (panorama) => {
if (!panorama.objectId) {
throw new Error('panorama id is required')
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的测试:
import {
checkPanoramaFormat
} from '@/common/helpers'
describe('checkPanoramaFormat', () => {
const panorama = { anotherProp: '1' }
it('creates clone', () => {
expect(checkPanoramaFormat(panorama)).toThrowError('hshshs')
})
})
Run Code Online (Sandbox Code Playgroud)
我希望终端能告诉我预期和我得到了什么.但我一无所获.事实上,Jest没有告诉我任何事情:
这是为什么以及如何解决它?
我有一个像这样的对象:
{
"index": 0,
"name": "b1a042ff6-0c75-4af2-a9da-1a16f333baee_p0",
"category": "others",
"rawUrl": "https://firebasestorage.googleapis.com/v0/b/vrcam-dev-5a815.appspot.com/o/5ab4f2a0-88e9-4bf5-86b5-61b528be707f/panoramas/panorama_XTsagLoxbA.png?alt=media&token=68ef261e-0c5e-4bf0-aebc-ab845fcec01a",
"isTopLogo": false,
"origin": "https://firebasestorage.googleapis.com/v0/b/vrcam-dev-5a815.appspot.com/o/5ab4f2a0-88e9-4bf5-86b5-61b528be707f/panoramas/panorama_XTsagLoxbA.png?alt=media&token=68ef261e-0c5e-4bf0-aebc-ab845fcec01a",
"position": {
"x": 0,
"y": 0
},
"panoramaRotation": {
"x": 0,
"y": 0,
"z": 0
}
}
Run Code Online (Sandbox Code Playgroud)
我想要unshift一个数组(它的克隆版本),如下所示:
[{
"adjustedRawUrl": "",
"category": "others",
"createdAt": 1514432540000,
"cubemapReady": false,
"desktopUrl": "https://im.ages.io/BGOLielt?cors&w=513",
"floorplanRotation": 0,
"index": 0,
"is720": false,
"isTopLogo": false,
"mobileUrl": "https://im.ages.io/BGOLielt?cors&w=4096",
"name": "b1a042ff6-0c75-4af2-a9da-1a16f333baee_p0",
"objectId": "3c312986-0ef1-42fc-9068-46fc13a04b8f",
"panoramaRotation": {
"x": 0,
"y": 0,
"z": 0
},
"position": {
"x": 0,
"y": 0
},
"rawUrl": "https://firebasestorage.googleapis.com/v0/b/vrcam-dev-5a815.appspot.com/o/5ab4f2a0-88e9-4bf5-86b5-61b528be707f/panoramas/panorama_lPea0mIc6H.png?alt=media&token=9e1494ff-2525-42a6-a058-12c26560349a",
"stereoUrl": "",
"thumbnail": …Run Code Online (Sandbox Code Playgroud)