小编Jer*_*mas的帖子

Vue 2.0:将异步数据传递给子组件

我有一个父Vue组件,通过prop将数据传递给它的子,但数据是异步可用的,因此我的子组件初始化为未定义的值.

在数据可用之前,我该怎么做才能防止初始化?

家长:

  var employees = new Vue({
    el: '#employees',
    data: { ... },
    methods: {
      fetch: function(model, args=null) {

      let url = "/" + model + ".json"
      console.log(url);
      $.ajax({
        url: url,
        success: ((res) => {
          console.log(res)
          this[model] = res;
          this.isLoading = false;
        error: (() =>  {
          this.isLoading = false;
        }),
        complete: (() => {
          // $('.loading').hide();
          this.isLoading = false;
        })
      })

    },
    mounted: function() {
      this.fetch(...)
      this.fetch(...)
      this.fetch('appointments')
    }
  })
Run Code Online (Sandbox Code Playgroud)

我的fetch方法被多次调用.

javascript asynchronous vue.js vuejs2

6
推荐指数
2
解决办法
3126
查看次数

Slick Slider:slickSetOption() 不会影响行

我有一个滑块:

<div class="super-slick responsive">
    <div class="profile-photo slider-image" style="height:400px;width:200px;background-color: blue;>
    </div>
    <div class="profile-photo slider-image" style="height:400px;width:200px;background-color: blue;>
    </div>
    <div class="profile-photo slider-image" style="height:400px;width:200px;background-color: blue;>
    </div>
    <div class="profile-photo slider-image" style="height:400px;width:200px;background-color: blue;>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

滑块:

$(".super-slider").slick({
    dots: true,
    slidesToShow: 4,
    slidesToScroll: 4,
    rows: 1
})
Run Code Online (Sandbox Code Playgroud)

...一切正常并且更新设置有效,但我似乎无法使用以下命令更新行数slickSetOption

super_slider.slick("slickSetOption", "slidesPerRow", 2)
super_slider.slick("slickSetOption", "slidesToScroll", 1)
super_slider.slick("slickSetOption", "rows", 2, true)
Run Code Online (Sandbox Code Playgroud)

但当我打电话时slickGetOption,它告诉我变化已经发生:

安慰:

> super_slider.slick("slickGetOption", "rows")
> 2
Run Code Online (Sandbox Code Playgroud)

javascript jquery slick.js

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

强制Excel在不格式化的情况下打开.csv

有没有一种方法可以强制Excel在不格式化的情况下打开.csv?我不希望它删除逗号并创建几列。我知道我可以在记事本中打开它,但我更喜欢使用excel。

excel

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

Heroku:连接中出现未知的SSL协议错误

我通过Heroku部署了我的应用程序,并使用自动证书管理工具添加SSL证书,因为我的旧手动添加证书已过期.添加我的证书并运行后,heroku certs我看到以下内容:

Name                Common Name(s)               Expires               Trusted  Type
??????????????????  ???????????????????????????  ????????????????????  ???????  ????
tyrannosaurs-53659  www.foobar.com               2017-10-15 12:59 UTC  True     ACM
Run Code Online (Sandbox Code Playgroud)

但是当我用curl我测试我的网址时,我看到:

$ curl -kvI https://www.foobar.com
* Rebuilt URL to: https://www.foobar.com/
*   Trying 54.243.71.103...
* TCP_NODELAY set
* Connected to www.foobar.com (54.243.71.103) port 443 (#0)
* Unknown SSL protocol error in connection to www.foobar.com:-9838
* Curl_http_done: called premature == 1
* Closing connection 0
curl: (35) Unknown SSL protocol error in connection to www.foobar.com:-9838
Run Code Online (Sandbox Code Playgroud)

导航到浏览器中的链接显示没有错误,但我很困惑为什么 …

ssl curl ruby-on-rails heroku

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

离子应用程序脚本构建错误

尝试构建我的应用程序时出现这个新错误。我什至不知道从哪里开始。错误很大,让我认为这是许多软件包的共同之处?

可能值得注意的是,@angular/tsc-wrapped autoprefixer由于我看到的另一个错误,我在此之前安装了一个软件包。在angular-cligithub 问题上,我看到人们用那个包解决了这个问题。

附带说明,第一个错误:

Error: ./node_modules/chart.js/src/core/core.helpers.js Module not found:
Run Code Online (Sandbox Code Playgroud)

当我查看我的node_modules文件夹时,我看到了那个确切的文件?它存在时是否有理由找不到它?

[18:10:50]  ionic-app-script task: "build" 
[18:10:50]  Error: ./node_modules/chart.js/src/core/core.helpers.js Module not found: Error: Can't resolve 
            'chartjs-color' in '/usr/src/app/node_modules/chart.js/src/core' resolve 'chartjs-color' in 
            '/usr/src/app/node_modules/chart.js/src/core' Parsed request is a module using description file: 
            /usr/src/app/node_modules/chart.js/package.json (relative path: ./src/core) Field 'browser' doesn't contain 
            a valid alias configuration after using description file: /usr/src/app/node_modules/chart.js/package.json 
            (relative path: ./src/core) resolve as module looking for modules in /usr/src/app/node_modules using 
            description file: /usr/src/app/package.json (relative path: ./node_modules) …
Run Code Online (Sandbox Code Playgroud)

npm ionic-framework angular-cli

5
推荐指数
0
解决办法
414
查看次数

Rails 4:在序列化程序中订购 has_many

我有一个带有has_many关联的序列化程序,我想订购依赖模型。由于某种原因,我收到一个undefined method key?'错误:

class API::ClientSerializer < ActiveModel::Serializer
    has_many :check_ins, -> { order(:week) }
end
Run Code Online (Sandbox Code Playgroud)

我还可以如何按周订购 check_ins?

serialization ruby-on-rails has-many ruby-on-rails-4

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

Ngx-Bootstrap 弹出窗口未设置正确的高度或宽度

我正在尝试在我的 Ionic 2 / Angular 2 应用程序中使用ngx-bootstrap,但由于某种原因,弹出窗口在我的视图中无法正确显示:

<button
  placement="right"
  [outsideClick]="true"
  popover="this is a teseofnwifo ef efo efoih wefohwefo wef  h ioef  whefhweofihwoeht"
  [isOpen]="true"
  triggers="click"

  ion-button full outline 
  class="flex-col rounded box-shadow" 
  color="primary" 
  style="height:100%;font-size:16px;border-width:1px;" 
  (click)="goTo('new-client')" #1>
  <i class="fa fa-user-plus text-shadow" padding style="font-size: 150px;color:red;"></i>
  <span style="font-size:32px;text-transform:none;">New Client</span>
</button>
Run Code Online (Sandbox Code Playgroud)

我不认为我的按钮样式应该影响弹出窗口,因为它呈现为单独的组件,但是当显示弹出窗口时,它的width和 都height设置为 4px。我不确定它是在哪里设置的,或者我是否在某个地方缺少一些 javascript 。

应用程序模块.ts

import { PopoverModule } from 'ngx-bootstrap/popover';

@NgModule({
  declarations: [...],
  imports: [
    PopoverModule.forRoot()
  ]
  ...
})
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

twitter-bootstrap ionic-framework bootstrap-4 ngx-bootstrap angular

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

由于 node-sass 错误,Ionic 无法构建应用程序

我正在尝试部署我的 ionic 应用程序,但它不断抛出以下错误:

ionic2Project@2.4.1 build /builds//awaken-app
> ionic-app-scripts build

/builds///node_modules/@ionic/app-scripts/node_modules/node-sass/lib/binding.js:15
      throw new Error(errors.missingBinary());
      ^

Error: Missing binding /builds///node_modules/@ionic/app-scripts/node_modules/node-sass/vendor/linux-x64-64/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x

Found bindings for the following environments:
  - OS X 64-bit with Node.js 12.
Run Code Online (Sandbox Code Playgroud)

这似乎与工作node-sass@4.12.0,但ionic-app-scripts具有node-sass@4.10.0在它的package.json

当我尝试在node-sass本地重建时,我看到以下错误:

$ npm rebuild node-sass

> node-sass@4.10.0 install /Users//node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.10.0/darwin-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.10.0/darwin-x64-72_binding.node": 

HTTP error 404 …
Run Code Online (Sandbox Code Playgroud)

sass node.js ionic-framework node-sass

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

使用 Javascript AWS 开发工具包生成预签名的 S3 URL

我试图允许从预先签名的 URL 访问资产,但我不确定如何执行此操作。从这个页面我可以看到我需要以下内容:

Authorization = "AWS" + " " + AWSAccessKeyId + ":" + Signature;

Signature = Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) );

StringToSign = HTTP-Verb + "\n" +
  Content-MD5 + "\n" +
  Content-Type + "\n" +
  Date + "\n" +
  CanonicalizedAmzHeaders +
  CanonicalizedResource;

CanonicalizedResource = [ "/" + Bucket ] +
  <HTTP-Request-URI, from the protocol name up to the query string> +
  [ subresource, if present. For example "?acl", "?location", "?logging", or "?torrent"];

CanonicalizedAmzHeaders = …
Run Code Online (Sandbox Code Playgroud)

javascript amazon-s3 amazon-web-services

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

带有可选变量的 Rails 部分不起作用

我不确定这里发生了什么,但以下内容会在渲染时引发错误:

<%= render 'clients/clients_table', special: true %> 
Run Code Online (Sandbox Code Playgroud)

在我的部分中,我有:

<% if defined?(:special) %>
    <p><%= special %></p> <!-- line with error -->
<% else %>
    <p>No</p>
<% end -%>
Run Code Online (Sandbox Code Playgroud)

这抛出错误:

undefined local variable or method `special' for #<#<Class:0x007fa20fbb0310>:0x007fa20cb986a0>
Run Code Online (Sandbox Code Playgroud)

当我尝试显示时,local_assigns.has_key?(:special)它也显示false. 知道发生了什么吗?

ruby-on-rails partial-views

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