小编KFu*_*unk的帖子

AngularJS Resource - PUT方法没有得到id

我有一个工厂,它返回我的文章模型的$资源:

angular.module('ADI.Resources').factory("Articles", ['$resource', function($resource) {
    return $resource('/api/v1/article/:articleId', {
        articleId: '@_id',
        _shop: window.user._shop
    }, {
        update: {
            method: 'PUT'
        }
    });
}]);
Run Code Online (Sandbox Code Playgroud)

GET,POST并且DELETE运行良好,但不是更新(PUT).这是我使用的代码:

Articles.update({articleId: '300000000000000000000001'}, function(article){
    console.log(article);
});
Run Code Online (Sandbox Code Playgroud)

这是在提出这个要求:

PUT http://localhost:3000/api/v1/article?_shop=100000000000000000000001
Run Code Online (Sandbox Code Playgroud)

代替:

PUT http://localhost:3000/api/v1/article/300000000000000000000001?_shop=100000000000000000000001
Run Code Online (Sandbox Code Playgroud)

知道为什么在执行更新时没有填充:articleId参数?谢谢!

angularjs angularjs-resource

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

如何使用 Service Worker 处理 index.html 文件的缓存?

我目前正在使用create-react-app默认服务工作者开发渐进式 Web 应用程序。

在发布我们的一个 javascript 块的新版本时,我遇到了破坏缓存的问题。

构建时,输出 javascript 文件使用 acontenthash来确保当 JS 文件中的内容更改时,文件名也会更改。在没有 Service Worker 的情况下运行时,这成功地破坏了缓存。

但是,在使用create-react-appService Worker 时,包括我的index.html文件在内的所有静态资产都会被缓存。这意味着旧index.html的将提供给用户,其中包括<script>我的旧缓存 javascript 文件的标签,而不是带有更新的 .js 文件的新文件contenthash

我已经弹出并修改了 webpack.config.jsWorkboxWebpackPlugin以排除我的 index.html 文件:

 new WorkboxWebpackPlugin.GenerateSW({
      clientsClaim: true,
      exclude: [/\.map$/, /asset-manifest\.json$/, /index.html/],
      importWorkboxFrom: "cdn",
      navigateFallbackBlacklist: [
          // Exclude URLs starting with /_, as they're likely an API call
             new RegExp("^/_"),
          // Exclude URLs containing a dot, as they're likely a resource in …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs service-worker create-react-app

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

使用Eve的DB层而不使用HTTP

在我的应用程序中,MongoDB集合需要通过服务器端脚本作业进行更新(IE:每隔30分钟从其他API中擦除/拉取一个cron作业).我真正想做的是对MongoDB集合进行更新,但是要根据模式验证数据并包含元数据(更新,创建等).

想到解决这个问题的两种方法是:

  1. 有一个假客户端做HTTP POST/PUT/PATCHES.但是,这意味着这个假客户端必须处理身份验证/授权/最后修改后的事情.
  2. 使用PyMongo直接与DB交互.但是,这意味着我不会进行数据验证或存储元数据.

Eve是否有数据库挂钩,以便我可以在没有HTTP的情况下进行Eve丰富的数据库更新?

eve

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

jQuery(文档).ready没有等待DOM准备好

我在标题中有一个非常微妙的动画.首次加载页面或使用cmd + shift + r(mac)刷新以清除缓存时,jQuery似乎并不等待DOM准备就绪.它会在所有正常的html/css弹出之前启动动画.

我只是误解了究竟是什么(文件).实际上已经做了什么?

jquery dom

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

RAML:嵌套模式

1)在编写RAML时,我可以在模式定义中使用嵌套吗?

例如:

schemas:
  - DNSResponse: |
      {
        "type": "object",
        "properties": {
            "AnswerSection": {
                "type": "array",
                "items": (((I want a re-useable schema here. ex: ARecord)))
            },
            "AA": {"type": "boolean"},
            "AD": {"type": "boolean"},
            ...
        }
      }
  - ARecord: |
      {
        "type": "object",
        "properties": {
            "address": "string",
            "ttl": "number",
            "name": "string"
        }
      }
Run Code Online (Sandbox Code Playgroud)

2)我可以在一组可嵌套模式周围使用选项/枚举吗?

"items": [ARecord, MXRecord, PTRRecord, ...]
Run Code Online (Sandbox Code Playgroud)

raml

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

使用 Jekyll 的 Collection relative_directory 来组织页面/集合

我认为设置relative_directory (Jekyll Collection Docs) (github PR)属性可以帮助我在不影响所需输出的情况下保持文件井井有条,但它似乎被忽略/不用于生成文件。我不希望我的收藏是在根目录下,因为我觉得它混淆有邻近〜10集合文件夹_assets_data_includes_layouts,和其他人。

欢迎修复或替代解决方案,只要输出相同,并且我的页面在他们自己的目录中,而无需permalink在每个页面上都放置前端。

_config.yaml

collections:
  root:
    relative_directory: '_pages/root'
    output: true
    permalink: /:path.html
  root-worthy:
    relative_directory: '_pages/root-worthy'
    output: true
    permalink: /:path.html
  docs:
    relative_directory: '_pages/docs'
    output: true
    permalink: /docs/:path.html
Run Code Online (Sandbox Code Playgroud)

目录结构:

??? ...
??? _layouts
??? _pages
?   ??? root
?   ?   ??? about.html
?   ?   ??? contact.html
?   ??? root_worthy
?   ?   ??? quickstart.html
?   ?   ??? seo-worthy-page.html
?   ??? docs
?       ??? errors.html
?       ??? api.html …
Run Code Online (Sandbox Code Playgroud)

jekyll

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