小编Ric*_*ore的帖子

使用Masonry.JS和Vue.JS

我知道如何使用masonry.js除了vue.但是,我有问题让它运行并在vue框架内正确调用.我在创建或准备好的内部调用它,但似乎都没有正确形成网格.我怎样才能让这个在框架内工作?哦,我确实在此脚本之前的html中调用了jquery.这是组件内部的内容:

编辑:

我可以看到砌体通过使用JS指定其高度并将项目更改为绝对位置来影响网格.但是,它没有正确放置它们.它将它们堆叠在彼此上面而不是像它应该在网格中的并排侧面. 在此输入图像描述

<template>
  <div class="projects--container">
    <div class="inner-section inner--options">
        <div class="grid">
            <div class="grid-item"></div>
            <div class="grid-item"></div>
            <div class="grid-item"></div>
        </div>
    </div>
  </div>
</template>

<script>
 export default{
    ready: function () {
        this.mason();
    },
     data: function () {
         return {
             options: [
                 {
                   option: 'projects',
                     phrase: 'for clients',
                     slogan: 'slogan...'
                 },
                 {
                     option: 'sides',
                     phrase: 'for us',
                     slogan: 'we love what we make'
                 },
                 {
                     option: 'moments',
                     phrase: 'with the crew'
                 }
             ]
         }
     },
     methods: {
         revert: function () {
             this.$dispatch('return-home', …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-masonry vue.js

16
推荐指数
3
解决办法
3744
查看次数

Laravel php foreach 循环按键获取值

我想我把这个简单的事情搞糊涂了。我只想获取我的密钥“周”和“天”的值。我已经尝试过以下方法:

\n\n
@foreach($years as $key3 => $year)\n                <h1>{{$key3}}</h1>\n                @foreach($year as $key2 => $months)\n                    <p>{{$key2}}</p>\n                    @foreach($months as $key1 => $days)\n                        <p>{{$days[\'weeks\']}}</p>\n                        <p>{{$days->weeks}}</p> //try two//\n                    @endforeach\n                @endforeach\n            @endforeach\n
Run Code Online (Sandbox Code Playgroud)\n\n

其响应此错误:

\n\n
Illegal string offset \'weeks\'\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我尝试循环的数组的示例:

\n\n
    array:4 [\xe2\x96\xbc\n  2016 => array:12 [\xe2\x96\xbc\n    "01" => array:2 [\xe2\x96\xbc\n      "weeks" => 5\n      "days" => "31"\n    ]\n
Run Code Online (Sandbox Code Playgroud)\n\n

有人可以帮助我理解我做错了什么吗?

\n

php foreach laravel

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

Laravel Eloquent将变量传递给关系函数

我正在使用eloquent来查询数据库条目及其对应关系.问题是我需要将$date变量传递给关系,query如下所示:

我可以将$date变量传递给第一个查询,因为它不在with函数中.我怎样才能实现第二个目标?

询问

    public static function find_task($type, $date) {
    if($type == 'student') {
        $mySid = Student::student_id();
        $allTasks = TaskAssignment::where('student_id', $mySid)
            ->with('task')
            ->where('dueDate', $date)
            ->orderBy('dueDate', 'asc')
            ->get();

    } elseif($type == 'teacher') {
        $myTid = Teacher::teacher_id();
        $allTasks = Tasks::where('teacher_id', $myTid)
            ->with(['assignment' => function ($query) {
                $query->where('dueDate', $date);
                $query->orderBy('dueDate', 'asc');

            }])->get();
    } else {
        return 'error this page does not exist';
    }

    return $allTasks;
}
Run Code Online (Sandbox Code Playgroud)

php mysql laravel

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

LARAVEL HOMESTEAD SQLSTATE [HY000] [1862]您的密码已过期.要登录,您必须使用支持过期密码的客户端进行更改

我整天都没有使用过期的mysql密码.我已经按照其他类似的问题但我继续得到相同的密码过期错误.我已经用homebrew卸载并重新安装了Mysql.我重新启动了mysql服务器.我已经删除,更改并创建了mysql中的宅基地用户,甚至卸载然后重新安装在此输入图像描述宅基地和流浪者.没有这个工作.我该怎么办?

在此输入图像描述

在此输入图像描述

编辑更新:

我可以使用续集专业版进入mysql:

在此输入图像描述

但在.env文件中有此重现过期的密码错误:

在此输入图像描述

在此输入图像描述

php mysql

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

使用Laravel的错误422 Ajax Post

我正在尝试使用Laravel 5发表一个简单的Ajax帖子。我读到Csrf令牌匹配存在问题,我可以将我的uri放入VerifyCsrfToken期望中以解决此问题。这部分起作用,但是现在我发帖时出现422错误。

在此处输入图片说明

在此处输入图片说明

我在代码中弄乱了吗?我该如何工作?这是我所拥有的:

HTML:

<div class = "q-form">
                    {!!Form::open(array('url' => 'questions')) !!}
                        <div class = "form-group">
                            {!! Form::hidden('user_id', $myid, ['class' => 'form-control']) !!}
                            {!!Form::label('title', 'Title:')!!}
                            {!!Form::text('title', null, ['class'=> 'form-control'])!!}

                            {!!Form::label('question', 'Question:')!!}
                            {!!Form::textarea('question', null, ['class'=> 'form-control area', 'placeholder' => 'What would you like to ask?'])!!}


                        {!!Form::submit('Ask!', ['class'=> 'btn btn-danger form-control ask'])!!}
                        </div>
                    {!! Form::close() !!}
                </div>
Run Code Online (Sandbox Code Playgroud)

JS:

$('.ask').click(function(e) {

       e.preventDefault();

       var postData = $(this).serializeArray();

       var base_url = 'http://rem-edu-es.eu1.frbit.net/';
       $.ajax({
           type: "POST",
           url: base_url + "questions",
           data: postData,
           success: function (data) { …
Run Code Online (Sandbox Code Playgroud)

javascript php ajax jquery

3
推荐指数
2
解决办法
9456
查看次数

循环通过关系Laravel

堆栈溢出,

我想要完成的事情:

我想循环通过数据库找到所有(英雄)与他们的相关(访谈).我还希望每次采访都与它相关(故事)和(图像).到目前为止,我可以dd($英雄),我可以看到阵列正确地抓住每个英雄的面试,每次采访都有相关的图像和故事.如何正确循环?

错误

Invalid argument supplied for foreach() (View: /Users/plastics1509moore/Desktop/elephant_gin/resources/views/administration/index.blade.php)
Run Code Online (Sandbox Code Playgroud)

这就是我所做的:

控制器:

$heroes = Hero::with('Interview', 'Interview.stories', 'Interview.images')->orderBy('position', 'asc')->get();
Run Code Online (Sandbox Code Playgroud)

模型关系:

英雄:

public function Interview()
{
    return $this->hasOne('App\Interview', 'heroInt_id');
}
Run Code Online (Sandbox Code Playgroud)

专访:

    public function relationships()
{
    return $this->belongsTo('App\Hero');
}
public function stories()
{
    return $this->hasMany('App\InterviewStory');
}
public function images()
{
    return $this->hasMany('App\InterviewImage');
}
Run Code Online (Sandbox Code Playgroud)

InterviewImage:

 public function relationships()
{
    return $this->belongsTo('App\Interview');
}
Run Code Online (Sandbox Code Playgroud)

InterviewStory

public function relationships()
{
    return $this->belongsTo('App\Interview');
}
Run Code Online (Sandbox Code Playgroud)

HTML:

环:

    @foreach($heroes as $hero)
       @foreach($hero->Interview as $story)
         <div>{{$story->id}}</div>
        @endforeach    
    @endforeach
Run Code Online (Sandbox Code Playgroud)

foreach relationship laravel

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

MaterializeCss模式错误openModal不是函数

我有所有要求Jquery,Materialize.js坐在我的Js文件上面然而我得到警告openModal不是一个函数..我检查模态名称是对的,我可以运行Materialize.toast所以我知道Materialise.js正在工作.使用按钮触发也不会调用模态.这是代码..

脚本:

<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/js/materialize.js"></script>
<script type="text/javascript" src="/js/video.js"></script>
<script src="/js/admin.js"></script>
Run Code Online (Sandbox Code Playgroud)

触发:

<button data-target="modal1" class="btn modal-trigger">Modal</button>
Run Code Online (Sandbox Code Playgroud)

莫代尔:

    <!-- Modal Structure -->
    <div id="modal1" class="modal">
        <div class="modal-content">
            <h4>Modal Header</h4>
            <p>A bunch of text</p>
        </div>
        <div class="modal-footer">
            <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

JS:

 var modal = document.getElementById('modal1');
  modal.openModal();
$('#modal1').leanModal();
$('#modal1').openModal();
Run Code Online (Sandbox Code Playgroud)

javascript jquery materialize material-design

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

将自定义 Js 添加到 Wordpress 主题

我有这个简短的 javascript,我想添加到客户的 wordpress 中。我不太了解 wordpress 的操作方式或在哪里添加我的代码。我在网上阅读了一些文章,但对如何解决这个问题有点困惑。我添加了我阅读的内容来注册脚本并告诉 wordpress 使用 Jquery,但我一直收到错误。在它没有注册它需要 jquery 之前。当我添加 wptuts_script 时,它现在无法识别。我是不是把这段代码放错了地方?这是js文件的文件路径html/wp-content/themes/metis/js基本上我想添加这个js(使用jquery):

document.ready(function() {

    function wptuts_scripts_with_jquery()
    {

        // or
        // Register the script like this for a theme:
        wp_register_script( 'custom-script', get_template_directory_uri() . '/js/test.js', array( 'jquery' ));

        // For either a plugin or a theme, you can then enqueue the script:
        wp_enqueue_script( 'custom-script' );
    }
    add_action( 'wp_enqueue_scripts', 'wptuts_scripts_with_jquery' );

    function updatebtm() {
        var pos = $(window).scrollTop();
        console.log(pos);
        if (pos >= 800) {
            $('.portfolio-top').css('display', 'none');

        } else {

            $('.portfolio-top').css('display', …
Run Code Online (Sandbox Code Playgroud)

javascript wordpress jquery

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