【问题标题】:Send file to Ember controller发送文件到 Ember 控制器
【发布时间】:2017-01-26 22:15:09
【问题描述】:

在 ember index.html 我使用组件发送动作并获取文件

<script type="text/x-handlebars" id="components/picture-upload">
    <input multiple="true" onchange={{action "upload"}}
    accept="image/png,image/jpeg,application/pdf"
    type="file"
    />
</script>
<script type="text/x-handlebars" id="upload">
    {{picture-upload upload='upload'}}
    {{outlet}}
</script>

app.js

App.UploadController=Ember.Controller.extend({
  actions:{
    upload:function (event) {
     //here to get file
  }
}});

App.PictureUploadComponent=Ember.Component.extend({
  actions:{
    upload(){
      //i want to send file but this is not good value
      this.sendAction('upload',this);
    }
  }
});

但我不知道如何发送事件,我需要类似 answer 的东西,之后我想用 ajax 将文件发送到服务器,但问题是如何获取文件!

【问题讨论】:

    标签: javascript ember.js handlebars.js


    【解决方案1】:

    PictureUploadComponent

    upload(event){
          //i want to send file but this is not good value
          this.sendAction('upload',event);
        }
    

    【讨论】:

      猜你喜欢
      • 2020-12-26
      • 2018-02-15
      • 1970-01-01
      • 2021-06-02
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      • 2019-03-18
      • 1970-01-01
      相关资源
      最近更新 更多