如何保持数据刷新页面?

时间:2017-08-08 05:11:19

标签: ember.js

我从模型中获取数据。将模型集成到页面后,当我刷新页面时,数据就会消失。

我想阻止数据仍在刷新。在EmberJs data中执行此操作的正确方法是什么,向我显示阻止export default Ember.Route.extend({ model: function(params) { return this.store.peekRecord('card-list', params.id ); //works } }); 刷新的正确方法?

我的型号代码:

    import Ember from 'ember';

    export default Ember.Route.extend({
      model: function(params) {

        if(this.store.hasRecordForId('card-list', params.id)){
            return Ember.RSVP.hash({
                model: this.store.peekRecord('card-list', params.id ) 
            })
        }
    //I am trying for refresh. but throws error as
//Error while processing route: cs2i.balance.balanceEdit Ember Data Request GET /api/card-lists/4196074912005007 returned a 404
        return Ember.RSVP.hash({
            model: this.store.findRecord('card-list', params.id ) 
        })
      }
    });

提前致谢。

更新

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

F:\>h:

H:\>cd conversion folder


H:\Conversion folder>ffmpeg ffmpeg -report -enable_drefs 1 -use_absolute_path 1
-i fdb9_AerialsEagleFarm_0610.mov -map 0:v -map 0:a -write_tmcd 1 fd9_AerialsEag
leFarm_A0609.mp4
ffmpeg started on 2017-08-08 at 15:01:24
Report written to "ffmpeg-20170808-150124.log"
ffmpeg version N-86950-g1bef008 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.1.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --e
nable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --
enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-li
bfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug -
-enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enabl
e-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-li
bsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolam
e --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
 --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable
-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 70.100 / 55. 70.100
  libavcodec     57.102.100 / 57.102.100
  libavformat    57. 76.100 / 57. 76.100
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 98.100 /  6. 98.100
  libswscale      4.  7.102 /  4.  7.102
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] Opening 'video.vid' for reading
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] stream 0, error opening alias: path
='/VibrintAVFiles/Xchange In/fdb9_AerialsEagleFarm_0610.vmf/video.vid', dir='fdb
9_AerialsEagleFarm_0610.vmf', filename='video.vid', volume='default', nlvl_from=
1, nlvl_to=1
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] Opening 'audio_0.pcm' for reading
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] stream 1, error opening alias: path
='/VibrintAVFiles/Xchange In/fdb9_AerialsEagleFarm_0610.vmf/audio_0.pcm', dir='f
db9_AerialsEagleFarm_0610.vmf', filename='audio_0.pcm', volume='default', nlvl_f
rom=1, nlvl_to=1
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] Opening 'audio_1.pcm' for reading
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] stream 2, error opening alias: path
='/VibrintAVFiles/Xchange In/fdb9_AerialsEagleFarm_0610.vmf/audio_1.pcm', dir='f
db9_AerialsEagleFarm_0610.vmf', filename='audio_1.pcm', volume='default', nlvl_f
rom=1, nlvl_to=1
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] Opening 'audio_2.pcm' for reading
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] stream 3, error opening alias: path
='/VibrintAVFiles/Xchange In/fdb9_AerialsEagleFarm_0610.vmf/audio_2.pcm', dir='f
db9_AerialsEagleFarm_0610.vmf', filename='audio_2.pcm', volume='default', nlvl_f
rom=1, nlvl_to=1
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] Opening 'audio_3.pcm' for reading
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] stream 4, error opening alias: path
='/VibrintAVFiles/Xchange In/fdb9_AerialsEagleFarm_0610.vmf/audio_3.pcm', dir='f
db9_AerialsEagleFarm_0610.vmf', filename='audio_3.pcm', volume='default', nlvl_f
rom=1, nlvl_to=1
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000005c99a0] Could not find codec parameters for
 stream 0 (Video: dvvideo (dvpp / 0x70707664), none, 720x576, 28800 kb/s): unspe
cified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Guessed Channel Layout for Input Stream #0.3 : mono
Guessed Channel Layout for Input Stream #0.4 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fdb9_AerialsEagleFarm_0610.mov':
  Metadata:
    creation_time   : 2016-10-06T07:01:58.000000Z
  Duration: 00:12:43.90, start: 0.000000, bitrate: 1 kb/s
    Stream #0:0(eng): Video: dvvideo (dvpp / 0x70707664), none, 720x576, 28800 k
b/s, SAR 118:81 DAR 295:162, 25 fps, 25 tbr, 2500 tbn, 2500 tbc (default)
    Metadata:
      creation_time   : 2016-10-06T07:01:58.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 01:17:27:12
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16,
 768 kb/s (default)
    Metadata:
      creation_time   : 2016-10-06T07:01:58.000000Z
      handler_name    : Apple Alias Data Handler
    Stream #0:2(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16,
 768 kb/s (default)
    Metadata:
      creation_time   : 2016-10-06T07:01:58.000000Z
      handler_name    : Apple Alias Data Handler
    Stream #0:3(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16,
 768 kb/s (default)
    Metadata:
      creation_time   : 2016-10-06T07:01:58.000000Z
      handler_name    : Apple Alias Data Handler
    Stream #0:4(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16,
 768 kb/s (default)
    Metadata:
      creation_time   : 2016-10-06T07:01:58.000000Z
      handler_name    : Apple Alias Data Handler
    Stream #0:5(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2016-10-06T07:01:58.000000Z
      handler_name    : Apple Handle Data Handler
      timecode        : 01:17:27:12
[NULL @ 00000000005cad20] Unable to find a suitable output format for 'ffmpeg'
ffmpeg: Invalid argument

2 个答案:

答案 0 :(得分:1)

您可以检查现有记录,除非提取该记录。

export default Ember.Route.extend({
  model: function(params) {
    if(this.store.hasRecordForId('card-list', params.id))
      return this.store.peekRecord('card-list', params.id );
    return this.store.findRecord('card-list', params.id );
  }
});

答案 1 :(得分:1)

你必须偷看'使用查询或findRecord或findAll等获取记录的父路线的记录...所以 - 可能有很多原因导致您的数据消失了......

如果你在某个孩子的路线上...... peekRecord没有任何东西可以偷看......所以,你必须检查记录......或者从父路线获取modelFor(&#39; model-name&#39;) - 所以,您需要提供有关代码上下文的更多信息。< / p>

// imports whatevers...
model(parameters) {
  return this.store.findRecord('thing', parameter.id);
}

...或

model() {
  var x = this.modelFor('parentModel');
  // do something with x... query... find etc...
}