我在 Chrome、移动设备上遇到了一些奇怪的功能。
当我尝试将焦点集中在 chrome 上的某个元素上时,当您尝试仅加载输入、 getItById 并执行 .focus() 时,它不起作用。但是,如果将其包装在附加到按钮的事件侦听器中,并用鼠标单击该按钮,则它可以正常工作。
因此,我试图通过查看是否可以调用 btn.click() 来欺骗它,但这不会激活 .focus()
尝试一下:在移动设备、chrome(至少对于 iOS)上加载页面。您应该收到“已单击”警报,但它不会关注输入。然后,尝试单击该按钮。您将收到警报并且焦点有效。
我发现这很有趣,想看看人们是否知道解决方法。
链接在这里 - jsfiddle
const btn = document.getElementById('button')
btn.addEventListener('click', () => {
alert('clicked')
const input = document.getElementById('input')
input.focus()
})
btn.click()Run Code Online (Sandbox Code Playgroud)
<input id="input" type="text">
<button id="button">Button</button>Run Code Online (Sandbox Code Playgroud)
编辑
我注意到的另一件事是,如果您让手机进入睡眠状态,然后再次打开它,则 focus() 无需单击即可工作。
编辑 2 - 添加了移动设备链接
我正在尝试找到用户位置的纬度和经度,以便我可以在viewdidload中将地图置于用户的中心位置.
我已经实现了似乎是正确的代码,但userLat(纬度)和userLon(经度)的值是关闭的.
NB有人和我有同样的问题,但他的答案从未得到解决: Mapbox iOS8 Swift mapView.showUsersLocation
import Mapbox
class ViewController: UIViewController, MGLMapViewDelegate, CLLocationManagerDelegate {
// let locationManager = CLLocationManager()
@IBOutlet weak var mapView: MGLMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Initalise map's center coordinate as vancouver
mapView.setCenterCoordinate(CLLocationCoordinate2D(latitude: 49.283382,
longitude: -123.117394),
zoomLevel: 15, animated: false)
view.addSubview(mapView)
// Set the delegate property of our map view to self after instantiating it.
mapView.delegate = self
// User location
mapView.showsUserLocation = true
let userLoc = mapView.userLocation!
userLoc.title = "Hello"
userLoc.subtitle = "I am …Run Code Online (Sandbox Code Playgroud) 我的内容拦截器所需的功能是隐藏._mqsbyoutube 上每个页面上带有类的 div,不包括包含youtube.com/results某处的url
第一条规则效果很好,隐藏了._mqsb域 youtube.com 的每个页面上的所有内容
results当域是 youtube.com 并且 URL 包含某处时,第二条规则应该忽略该规则。但当我使用https://m.youtube.com/results?q=eric+andre&sm=1或任何其他搜索查询时,它似乎并没有忽略前面的代码。
这是我的 blockerList.json 中的代码:
{
"trigger": {
"url-filter": ".*",
"if-domain": ["*youtube.com"]
},
"action": {
"type": "css-display-none",
"selector": "._mqsb"
}
},
{
"trigger": {
"url-filter": ".*results.*",
"if-domain": ["*youtube.com"]
},
"action": {
"type": "ignore-previous-rules"
}
}
Run Code Online (Sandbox Code Playgroud) 我的应用程序用户集合中的每个文档都有一个子集合。该子集合存储与用户相关的文档,但是也可以将它们保存到主集合中,每个文档都具有关联的userId。
我选择了这种结构,因为它在当时似乎最为明显,但是我可以想象,如果我需要进行数据库维护,它将使事情变得更加艰难。例如,如果要清理这些文档,则必须先查询每个用户,然后再查询每个用户的文档,而如果我拥有主集合,则可以查询所有文档。
That lead me to question what is the point of subcollections at all, if you can just associate those docs with an ID. Is it solely there so that you can expand if your doc becomes close to the 1MB limit?
noob 命令行用户在这里...
我正在尝试设置一个 postGIS 数据库,而互联网告诉我,我需要进入/etc我的服务器的目录。该目录确实存在并且我已经进入过它,但该ls -a命令未列/etc为其目录之一。
为什么不显示/etc?作为额外的好处 - 是否还有其他未列出的特殊情况ls -a?
ios ×2
javascript ×2
firebase ×1
html ×1
json ×1
ls ×1
mapbox ×1
regex ×1
unix ×1
userlocation ×1