我仅在新创建的cordova应用上添加
<script src="https://www.gstatic.com/firebasejs/6.1.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.1.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.1.1/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.1.1/firebase-database.js"></script>
<script type="text/javascript" src="js/firebase.js"></script>
之后
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
在index.html中。
firebase.js具有firebase配置和简单的注册功能。
var firebaseConfig = {
//firebaseconfigurations
};
firebase.initializeApp(firebaseConfig);
const email="random@email.com";
const password="password";
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
});
它给出4个错误,例如
Refused to load the script 'https://www.gstatic.com/firebasejs/6.1.1/firebase-app.js' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'". Note that 'script-src-elem' was not explicitly set, so 'default-src' is used as a fallback.