ฉันกำลัง chrome องเบราว์เซอร์เลื่อนเวลาออกไปหน่อย ตอนที่ฉันพยายามเชื่อมต่อ firebase กับเว็บโปรแกรมเกี่ยใน 2 ทางที่เป็นไปได้ไม่มีใครคือทำงานอยู่
- ใช้"npm ติดตั้ง firebase" ตอนที่ฉันพยายามคำสั่งนี้เพื่อติดตั้ง firebase เข้ามาอยู่ในโครงการโฟลเดอร์และเขียน fireConn.js แฟ้มพร้อมกับการปรับแต่งผมได้จาก firebase โครงการสร้างขึ้นมาออนไลน์
import {initializeApp} from 'firebase/app';
import {getFirestore} from 'firebase/firestore';
ข้อผิดพลาดที่ฉันมีคือ
Uncaught TypeError: Failed to resolve module specifier "firebase/app". Relative references must start with either "/", "./", or "../".
- ใช้ https://www.gstatic.com/firebasejs/9.4.1/firebase-app.js ที่อยู่ url ที่จะเข้าไปเกี่ยวข้องกับ firebase
import {initializeApp} from "https://www.gstatic.com/firebasejs/9.4.1/firebase-app.js";
import {getFirestore} from "https://www.gstatic.com/firebasejs/9.4.1/firebase-firestore.js";
เป็นของโครงการคือ chrome ส่วนขยาย,ฉันมีรายการlanguage แฟ้มซึ่งเป็นในรูปแบบต่อไปนี้:
{
"name": "xxx",
"manifest_version": 3,
"version": "1.0",
"permissions": ["cookies","tabs"],
"host_permissions": ["<all_urls>"],
"action": {
"default_popup": "popup.html"
},
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'",
"sandbox": "sandbox allow-scripts; script-src 'self' 'https://apis.google.com/' 'https://www.gstatic.com/' 'https://*.firebaseio.com' 'https://www.googleapis.com' 'https://ajax.googleapis.com'; object-src 'self'"
}
}
ข้อผิดพลาดซึ่งฉันกำลังจะเป็น:(มีบางอย่างผิดพลาดเกิดขึ้นกับ content_security_policy)
Refused to load the script 'https://www.gstatic.com/firebasejs/9.4.1/firebase-firestore.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.