小编mon*_*ece的帖子

http POST 上的 net::ERR_SSL_PROTOCOL_ERROR 到 Express 服务器

我试图从反应客户端发布到本地主机上的快速服务器,我在谷歌浏览器中收到此错误。

反应应用程序:http://localhost:3000 表达应用程序:http://localhost:5000

POST https://localhost:5000/upload net::ERR_SSL_PROTOCOL_ERROR
Run Code Online (Sandbox Code Playgroud)

我没有任何 SSL https 自签名证书,但我需要吗?我在我的 Express 应用程序的目录中使用了 create-react-app 来引导我的前端,所以我不知道某个地方的 webpack 设置是否试图将 http 作为 https 来处理这个特定的操作?

我没有对我的 Express js 应用程序使用任何引导,我将在下面包含我的服务器文件以供参考。

const express = require ('express')
const bodyParser = require ('body-parser')
const port = 5000

var app = express()
var cors = require("cors");

app.use(cors())
app.use(bodyParser())
app.listen(port, () => console.log(`Example app listening on port ${port}!`))



app.post('/upload', (req,res)=>{
    if (req.files === null ){
        return res.status(400).json({message: 'no image uploaded please try again'})
    }else{
        const file = req.files.file
        let …
Run Code Online (Sandbox Code Playgroud)

ssl node.js express reactjs

9
推荐指数
2
解决办法
4万
查看次数

从 vue.js 中的子发射传递时,值未定义

我不确定为什么会发生这种情况,因为我的两个方法(父级和子级都被调用)但实际数据没有被传递,即使当我尝试传递一个简单的字符串时,数据在记录时也是“未定义”的我的父母从emit接收数据:(

有人可以帮助我或者提供解释吗?

我的应用程序在 dom 中的渲染方式如下(这是 html 注入的一部分,而不是 vue-cli)

<div id="app">
    <div>
      <b-button v-b-modal.modal-1>upload files</b-button>

      <b-modal id="modal-1" title="BootstrapVue" ok-title="upload">
          <div>
              <file-uploader v-on:child-to-parent="logChildData()"></file-uploader>
          </div>
      </b-modal>
    </div>
  </div> 
Run Code Online (Sandbox Code Playgroud)

这是我的子组件

//component constructor
var fileUploader = Vue.extend({
  template: ' <div><div id="container" class="flexContainer"><div v-for="img in images" :key="img.name"><div :id=img.name><img height="80px" width="80px" :src=img.src alt="uploaded image"><button @click="removeItem(img.name)">X</button></div></div></div><input type="file" multiple @input="handleUpload($event)"></div>',
  data() {
      return {
        images:[],
        pdfs:[], 
      }
    },

    methods: {

      //send files back up to parent component where they can be manipulated
        sendDatatoParent(){
          console.log('sending data to parent')
          this.$emit('child-to-parent', 'a …
Run Code Online (Sandbox Code Playgroud)

html javascript vue.js

4
推荐指数
1
解决办法
3803
查看次数

未捕获的类型错误:db.collection 不是 firebase 中实时数据库的函数

当我尝试访问我的收藏时,出现以下错误。我的 firebase 应用程序在我的主应用程序组件内初始化。

我没有在这里包含配置对象,但我知道它可以工作,因为我也在我的应用程序中使用了 firebase auth,它工作得非常好。应用程序.js

componentDidMount(){
  if (!firebase.apps.length) {
    firebase.initializeApp(firebaseConfig);
  }
}
Run Code Online (Sandbox Code Playgroud)

我试图进行数据库调用的组件


componentDidMount(){

const db = firebase.database();
const ref = db.collection('Users/Notes').doc()

  let getDoc = ref.get()
  .then(doc => {
    if (!doc.exists) {
      console.log('No such document!');
    } else {
      console.log('Document data:', doc.data());
    }
  })
  .catch(err => {
    console.log('Error getting document', err);
  });
}

Run Code Online (Sandbox Code Playgroud)

我通过将它包含在 App.js 中来立即呈现这个组件,我不知道这是否可能是一个问题?

firebase react-native firebase-realtime-database google-cloud-firestore

1
推荐指数
1
解决办法
4426
查看次数