我有 2 個輸入字段以及 Map div,這里當我切換時,選項卡焦點將從第一個輸入字段轉到地圖內的名稱和鏈接,在傳遞到所有地圖名稱后,它到達第二個輸入字段。我嘗試在地圖函數內將 tabindex 設置為 -1,但沒有任何效果。任何人都可以幫助我,如何使這項工作有效。TS: var map = new window["google"].maps.Map(this.gmapElement.nativeElement, { center: { lat: 37.1587963, lng: -100.5623315 }, zoom: 2 }); google.maps.event.addListener(map, "titlesLoaded", function() { [].slice.apply(this.gmapElement.nativeElement).forEach(function(item) { item.setAttribute("tabindex", "-1"); });HTML: <div class="col" > <a href="javascript:void(0);" tabindex="-1">View on Map</a> <div style="position: relative; overflow: hidden;width:100%;height:400px" #mapRef> </div>演示版
1 回答
當年話下
TA貢獻1890條經驗 獲得超9個贊
正如我在評論中所說,您只需在 2 個輸入上添加tabindex="1"和即可。tabindex="2"
工作代碼片段:
var map;
function initialize() {
// Create the map and center on deault location
map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(0, 0),
zoom: 3
});
}
#map {
height: 120px;
width: 100%
}
<input type="text" tabindex="1">
<div id="map"></div>
<input type="text" tabindex="2">
<!-- Replace the value of the key parameter with your own API key. -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&callback=initialize" async defer></script>
- 1 回答
- 0 關注
- 156 瀏覽
添加回答
舉報
0/150
提交
取消
