小编ada*_*m78的帖子

点击时Vue.js切换类

你如何在vue.js中切换一个类?

我有以下内容:

<th class="initial " v-on="click: myFilter">
    <span class="wkday">M</span>
</th>

new Vue({
  el: '#my-container',
  data: {},
  methods: {
    myFilter: function(){
      // some code to filter users
    }
  }
});
Run Code Online (Sandbox Code Playgroud)

当我点击th我想要active作为一个类申请如下:

<th class="initial active" v-on="click: myFilter">
    <span class="wkday">M</span>
</th>      
Run Code Online (Sandbox Code Playgroud)

这需要切换,即每次点击它需要添加/删除类.

你是如何在vue.js中做到这一点的?

css vue.js

62
推荐指数
7
解决办法
16万
查看次数

Localhost的Googlemaps API密钥

如何获取googlemaps api密钥才能在localhost上运行?

我已经创建了一个API密钥,在参考文献中我添加了以下内容:

Accept requests from these HTTP referrers (websites) (Optional)

Use asterisks for wildcards. If you leave this blank, requests will be 
accepted from any referrer. Be sure to add referrers before using this key 
in production. 

localhost
Run Code Online (Sandbox Code Playgroud)

这不起作用,如果我排除api键它也不起作用?

google-maps api-key google-maps-api-3

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

"IEnumerable <>"类型在未引用的程序集中定义

我已将以下nuget包添加到我的MVC 5应用程序X.PagedList.Mvc中

我在控制器/视图中返回结果如下:

// Repo
public IPagedList<Post> GetPagedPosts(int pageNumber, int pageSize)
{
   var posts = _context.Post
      .Include(x => x.Category)
      .Include(x => x.Type);

   // Return a paged list
   return posts.ToPagedList(pageNumber, pageSize);

}

// View model
public class PostViewModel
{
   public IPagedList<Post> Posts { get; set; }
   ...
}

// Controller method
public ActionResult Index(int? page)
{

    int pageNumber = page ?? 1;
    int pagesize = 5;

    var posts = _PostRepository.GetPagedPosts(pageNumber, pagesize);

    var viewModel = new PostViewModel
    {
        Posts = posts,
        ... …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-mvc pagedlist

17
推荐指数
2
解决办法
7190
查看次数

如何清除bootstrap模态隐藏

如何在关闭/隐藏/关闭时清除bootstrap模式?

我有以下模态定义:

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
   Add New Comment
</button>
Run Code Online (Sandbox Code Playgroud)

包含模态的局部视图

@Html.Partial("_CreateComment", Model)


 // Partial view which contains modal

 <div class="modal fade" id="myModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
      @using (Ajax.BeginForm("AddComment", "Blog", new AjaxOptions
            {
                HttpMethod = "POST",
                InsertionMode = InsertionMode.Replace,
                UpdateTargetId = "comments",
                OnSuccess = "$('#myModal').modal('hide');"

            }))
      {
        <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">Add Comment</h4>
        </div>
        <div class="modal-body">
                @Html.ValidationSummary(true)
                @Html.HiddenFor(model => model.Blog.BlogID)

                <div class="form-group">
                    @Html.LabelFor(model => model.BlogComment.Comment)
                    @Html.TextAreaFor(model => …
Run Code Online (Sandbox Code Playgroud)

jquery twitter-bootstrap bootstrap-modal

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

在Laravel工厂模型中添加关系

我正在尝试添加一个工厂模型的关系来做一些数据库种子,如下所示 - 注意我正在尝试为每个用户添加2个帖子

public function run()
{
   factory(App\User::class, 50)->create()->each(function($u) {
         $u->posts()->save(factory(App\Post::class, 2)->make());
   });
}
Run Code Online (Sandbox Code Playgroud)

但它抛出以下错误

Argument 1 passed to Illuminate\Database\Eloquent\Relations\HasOneOrMany::s  
ave() must be an instance of Illuminate\Database\Eloquent\Model, instance 
of Illuminate\Database\Eloquent\Collection given
Run Code Online (Sandbox Code Playgroud)

我认为它与保存集合有关.如果通过分别调用帖子的每个工厂模型重新编写代码,它似乎工作.显然这不是很优雅,因为如果我想坚持10或发布给每个用户,那么我必须decalare 10或行,除非我使用某种for循环.

public function run()
{
   factory(App\User::class, 50)->create()->each(function($u) {
     $u->posts()->save(factory(App\Post::class)->make());
     $u->posts()->save(factory(App\Post::class)->make());
   });
}
Run Code Online (Sandbox Code Playgroud)

*更新*

有没有什么方法可以将模型工厂嵌套到第3层?

public function run()
{
   factory(App\User::class, 50)
       ->create()
       ->each(function($u) {
           $u->posts()->saveMany(factory(App\Post::class, 2)
                    ->make()
                    ->each(function($p){
                          $p->comments()->save(factory(App\Comment::class)->make());
          }));
   });
}
Run Code Online (Sandbox Code Playgroud)

factory relationship laravel-5.1

13
推荐指数
4
解决办法
9070
查看次数

Vue.js计算属性不起作用

我有一个用户数据对象,其中包含first_name和last_name以及一个返回全名的计算属性,但以下似乎在我的v-for指令中不起作用?

new Vue({

        el: '#content',

        data: {
          "users": [
            {
              "id": 3,
              "first_name": "Joe",
              "last_name": "Blogs"
            },
            {
              "id": 3,
              "first_name": "Jane",
              "last_name": "Doe"
            }
          ]
       },
        computed: {
           fullName: function (user) {
                return user.first_name + ' ' + user.last_name;
            }

        }

    });



    <tr v-for="user in users | orderBy fullName(user)">
          <td class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
              {{fullName(user)}} 
         </td>
    <tr>
Run Code Online (Sandbox Code Playgroud)

vue.js computed-properties

13
推荐指数
3
解决办法
3万
查看次数

Hangfire Dashboard授权配置不起作用

我已经下载了nu-get包 Hangfire.Dashboard.Authorization

我正在尝试按照以下文档配置基于OWIN的授权,但我得到intellisense错误 DashboardOptions.AuthorizationFilters is obsolete please use Authorization property instead

我也得到intellisense错误 The type or namespace AuthorizationFilter and ClaimsBasedAuthorizationFilterd not be found

using Hangfire.Dashboard;
using Hangfire.SqlServer;
using Owin;
using System;

namespace MyApp
{
    public class Hangfire
    {
       public static void ConfigureHangfire(IAppBuilder app)
        {
           GlobalConfiguration.Configuration
           .UseSqlServerStorage(
               "ApplicationDbContext",
                new SqlServerStorageOptions 
                  { QueuePollInterval = TimeSpan.FromSeconds(1) });

           var options = new DashboardOptions
           {
               AuthorizationFilters = new[]
               {
                  new AuthorizationFilter { Users = "admin, superuser", Roles = "advanced" },
                  new ClaimsBasedAuthorizationFilter("name", "value")
               }
           };

           app.UseHangfireDashboard("/hangfire", …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc owin hangfire

12
推荐指数
2
解决办法
9127
查看次数

Mysql - 如何比较两个Json对象?

将整个MySql json列与json对象进行比较的语法是什么?

以下不起作用:

select count(criteria) from my_alerts where criteria = '{"industries": ["1"], "locations": ["1", "2"]}'
Run Code Online (Sandbox Code Playgroud)

即使条件列有值,我也会得到0 {"industries": ["1"], "locations": ["1", "2"]}

如果我错了,请纠正我,但如果两个JSON对象具有相同的密钥集,则每个密钥在两个对象中具有相同的值.键和值的顺序将被忽略.那以下应该是一样的?

 {"industries": ["1"], "locations": ["1", "2"]} = {"locations": ["2", "1"], "industries": ["1"]}
Run Code Online (Sandbox Code Playgroud)

*更新*

我已经设法通过转换为json来实现它,如下所示:

select count(criteria) from my_alerts where criteria = CAST('{"industries": ["1"], "locations": ["1", "2"]}' AS JSON)
Run Code Online (Sandbox Code Playgroud)

然而,虽然在比较期间忽略了键的顺序,但仍然比较值的顺序.所以以下是假的:

{"locations": ["1", "2"]} = {"locations": ["2", "1"]}
Run Code Online (Sandbox Code Playgroud)

有没有办法强制比较忽略值的顺序呢?

mysql json

11
推荐指数
2
解决办法
4402
查看次数

如何在php中设置http响应状态代码和消息

我有页面检查通过HTTP POST(http://example.com/http_post)发送的数据.如果数据是好的,我添加到数据库并希望将http响应代码201和成功消息设置为http响应.如果不是我收集数组中的错误,并希望将http响应代码和消息设置为序列化JSON数组作为http响应.

1)什么是在PHP中将错误数组序列化为JSON的语法?

{
  "message": "The request is invalid.",
    "modelState": {
      "JobType": [ "Please provide a valid job type eg. Perm"]
  }
}
Run Code Online (Sandbox Code Playgroud)
  1. 是什么语法设置并将http响应返回到412.

  2. 是什么语法设置并返回http响应体中的序列化JSON,如上所述.

一个示例将有助于如何设置所有这些http响应标头.

谢谢

php json httpresponse http-headers

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

如何查询在数据库表中存储为 iCal RRULE 的定期约会?

如果我有一个包含以下列的约会表,我如何查询规则以提取发生在特定日期或两个日期之间的约会?

Appointments
------
id
name
dt_start
dt_end
rrule
Run Code Online (Sandbox Code Playgroud)

例如,假设我有一个约会,从 2016 年 9 月 28 日开始,到 2017 年 4 月 28 日结束,并且每两周在周一、周五到 2017 年 4 月 28 日发生一次。以下将是 RRule:

RRULE:FREQ=WEEKLY;INTERVAL=2;UNTIL=20170428T230000Z;BYDAY=MO,FR EXDATE:20170414T023000Z
Run Code Online (Sandbox Code Playgroud)

因此,使用上面的示例,上述约会发生的一些日期将包括以下内容:

2016-09-30 FRI
2016-10-10 MO
2016-10-14 FRI
2016-10-24 MO
Run Code Online (Sandbox Code Playgroud)

现在如何使用 SQL 或任何其他方法查询此表以提取 2016 年 10 月 10 日发生的所有约会?

为了记录,这将在 C# asp.net 和 SQL 服务器中完成。是否有可用于解析和查询规则的 C# 或 SQL Server 库?

我看过ICAL.net,但似乎没有太多关于它的文档,或者我将如何使用它来达到上述目的。

有没有人对 ICAL.net 有任何经验?

sql sql-server jquery icalendar rrule

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