ฉันต้องการเพื่อพัฒนาการ Chrome วนขยายแฟ้มซึ่งคงจะได้พูดถึงประเด็นสำคัญกับใบรายการเวอร์ชั่น 3 คน,แต่ฉันเจอปัญหากับกาผู้ใช้งานปัจจุบันคือการระบุพิกัดตำแหน่งพิกัดซึ่งทำงานกับปรากฏออกรุ่น 2,แต่สำหรับใบรายการเวอร์ชั่น 3 มันโยงนั้น navigator.geolocation
คือทำดัชนีเทียบสี.
นี่คือของรายการและ language background.js แฟ้ม:
รายการlanguage:
"name": "Chrome Extension MV3",
"description": "Learning all about Chrome Extensions Manifest Version 3!",
"version": "0.1.0",
"manifest_version": 2,
"background": {
"service_worker": "background.js"
},
"permissions": ["geolocation"]
}
background.js:
navigator.geolocation.getCurrentPosition((position) => {
const { latitude, longitude } = position.coords;
console.log(latitude, longitude);
});