小编Mar*_*rco的帖子

Angular - 如何从一个页面链接到另一个页面并在不使用id的情况下滚动到离子中的锚点

我正在开发一个离子应用程序.其中包含我的主页上的文章列表,每篇文章都有一个评论图标,该图标应作为文章页面中评论部分的链接.

如何从该首页链接到文章页面评论部分的锚点?

更新

由于Angular在#之后使用"URL",因此无法通过id链接到锚点,这是在答案中建议的,所以我正在寻找另一种方法来实现它.我尝试了几种解决方案,但以下都没有效果.

在这里,有时我得到一个正确的顶部偏移值,但是当我改为另一个文章页面时,该值保持不变.

这是我做的代码:

文章列表查看:

<a ng-click="commentLink({{article.id}})">
              <img class="social-images" src="icons/comment.svg"/> {{ article.comments.length }}
            </a>
Run Code Online (Sandbox Code Playgroud)

文章查看:

<a name="comments-section"></a>
Run Code Online (Sandbox Code Playgroud)

控制器:

$scope.commentLink = function(articleId) {
    return $state.go('main.article', {id: articleId}).then(function(state) {
      var position = $ionicPosition.offset(angular.element(document.getElementsByName('comments-section')));
      console.log(position.top);
      $ionicScrollDelegate.scrollTo(position.left, position.top);
    })
  };
Run Code Online (Sandbox Code Playgroud)

我也试过这个,基于这篇文章,但仍然没有运气:

控制器:

$location.hash('comments-section');
  var handle = $ionicScrollDelegate.$getByHandle('articleDelegate');
  handle.anchorScroll(true);
Run Code Online (Sandbox Code Playgroud)

视图:

<ion-content delegate-handle="articleDelegate">

<a id="comments-section"></a>
Run Code Online (Sandbox Code Playgroud)

javascript angularjs ionic-framework

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

React pdf js - 警告:设置假工人

我正在使用React pdf 查看器,我想在本地设置工作人员。我尝试过这样做:

import pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";

<Worker workerUrl={pdfjsWorker}>
    <Viewer
      fileUrl={url}
      defaultScale={SpecialZoomLevel.PageFit}
      plugins={[
        defaultLayoutPluginInstance
      ]}
    />
  </Worker>
Run Code Online (Sandbox Code Playgroud)

但是,这会引发一个警告:

警告:设置假工人

那么导入工人的正确方法是什么,为什么我会收到此警告?

javascript pdf.js reactjs service-worker

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

Laravel时间戳节省时间为unix时间戳

我想知道在laravel中更改最简单的方法是将数据库中的时间戳保存为unix有效时间戳?

提前致谢!

laravel

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

Laravel - 按出现次数获取前 5 名

我有表评论、投票、观点、喜欢,其中有article_id 字段。我试图根据这些表中出现的次数获取前 5 篇文章。我正在发送$modelName到我的函数,然后尝试从查询中获取结果。这就是我的查询现在的样子:

\n\n
private function query($modelName) {\n        $mostSomethingArticle = $modelName->all()->groupBy('article_id')->take(5);\n\n        return $mostSomethingArticle;\n\n      }\n
Run Code Online (Sandbox Code Playgroud)\n\n

现在,我得到这样的结果:

\n\n
Collection {#398 \xe2\x96\xbc\n  #items: array:5 [\xe2\x96\xbc\n    5 => Collection {#377 \xe2\x96\xbc\n      #items: array:5 [\xe2\x96\xb6]\n    }\n    2 => Collection {#376 \xe2\x96\xbc\n      #items: array:1 [\xe2\x96\xb6]\n    }\n    6 => Collection {#397 \xe2\x96\xbc\n      #items: array:3 [\xe2\x96\xb6]\n    }\n    1 => Collection {#396 \xe2\x96\xbc\n      #items: array:1 [\xe2\x96\xb6]\n    }\n    7 => Collection {#395 \xe2\x96\xbc\n      #items: array:5 [\xe2\x96\xb6]\n    }\n  ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想知道如何进行查询,以获取前 5 个结果以及按顺序出现的次数'desc'

\n

php mysql eloquent laravel-5

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

将ngrok设为家庭主妇

我正在尝试在我的宅基地上设置ngrok,但它没有打开我的项目.我已经运行ngrok http 80并将输出的一部分转发到我的Homestead.yaml文件中以将其映射到我的项目,并在此之后运行vagrant provision:

Forwarding                    http://92832de0.ngrok.io -> localhost:80
Forwarding                    https://92832de0.ngrok.io -> localhost:80
Run Code Online (Sandbox Code Playgroud)

但是当我在浏览器中打开http://92832de0.ngrok.io时,它打开了ngrok页面"它工作",而不是我的项目.

当我将端口更改为ngrok http 8000然后我收到Laravel错误消息:

哎呀,看起来像出事了.

ngrok homestead

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

Laravel 5.3 - 更改身份验证视图路径

在我的 Laravel 应用程序中,我对管理员和用户有不同的身份验证。所以我也有不同的看法。我已将 authviews文件夹放在admin文件夹中,以便我的管理员身份验证的视图路径现在admin.auth.login是例如。我在哪里可以更改这些路径,以便我可以将它们用于所有身份验证功能?

laravel-5.3

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

Laravel - 一般错误:1366 不正确的整数值

当我尝试保存或更新模型时,对于 spid_id 字段,出现以下错误。我不确定出了什么问题。

一般错误:1366 不正确的整数值:第 1 行的列 'spid_id' 的 ''(SQL:更新magazinesspid_id= , updated_at= 2016-10-21 08:28:46, summary= where id= 8)

这是我的桌子的样子:

       Schema::create('magazines', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('visual_id')->nullable();
            $table->integer('spid_id')->nullable();
            $table->timestamps();
        }); 
Run Code Online (Sandbox Code Playgroud)

我试图通过进行迁移将我的 spid_id 更改为在数据库中不可为空,因为我认为这可能是一个原因:

        Schema::table('magazines', function (Blueprint $table) {
            $table->integer('spid_id')->change();
        });
Run Code Online (Sandbox Code Playgroud)

但是该字段仍然可以为空。

这是我创建表单的商店功能:

        $magazine = Magazine::create([
          'name' => $request->input('name'),
          'visio_link_prefix' => $request->input('visio_link_prefix'),
          'spid_id' => $request->input('spid_id'),
          'summary' => $request->input('summary'),
        ]);
Run Code Online (Sandbox Code Playgroud)

php mysql laravel

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

即使类型正确,打字稿也会因类型错误而抛出错误

我第一次使用React YouTube 包,我正在尝试在 React 组件中嵌入和自定义 YouTube 播放器:

\n
const options = {\n  height: \'auto\',\n  width: \'100%\',\n  playerVars: {\n    // https://developers.google.com/youtube/player_parameters\n    controls: 0\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

从文档中我可以看到我使用了正确的参数,但是如果我尝试像这样传递它们:

\n
<YouTube videoId="xyQ5qD-u-J7" opts={options} ref={videoElement}/>\n
Run Code Online (Sandbox Code Playgroud)\n

但是,打字稿抛出错误:

\n
TS2769: No overload matches this call. \xc2\xa0\xc2\xa0Overload 1 of 2, \'(props: YouTubeProps | Readonly<YouTubeProps>): YouTube\', gave the following error. \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0Type \'{ height: string; width: string; playerVars: { controls: number; }; }\' is not assignable to type \'Options\'. \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0The types of \'playerVars.controls\' are incompatible between these types. …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs

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

Laravel - 没有在表格中写新内容

我已经通过迁移向我的数据库中的表添加了一个新列.该列已正确创建.但是当我试图给它写值时,什么都没有写出来.这是我的代码:

if ($alternativeId > 0) {
            $answered = 'yes';
        }
        else {
            $answered = 'not';    
        }

        $answer = Answer::create([
            'question_id' => $questionId,
            'player_id' => $player->id,
            'quiz_id' => $quiz->id,
            'score' => $score,
            'answered' => $answered
        ]);
Run Code Online (Sandbox Code Playgroud)

变量$ answers得到一个值,我在控制台中测试过,当我用它测试时:

return ['answered' => $answered]
Run Code Online (Sandbox Code Playgroud)

我在那里得到了正确的值,但没有在DB中写入任何内容.不知道为什么会这样?

php mysql laravel

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

Vue/Laravel 5.3 - 组件模板未在视图中显示

我试图在我的视图中第一次使用Vue组件.我创建了一个如下所示的文件assets/js/components/ImageUpload.vue:

<template>
<div>
  <div v-if="!image">
    <h2>Select an image</h2>
    <input type="file" @change="onFileChange">
  </div>
  <div v-else>
    <img :src="image" />
    <button @click="removeImage">Remove image</button>
  </div>
</div>
</template>

<script>
export default {
    data: { image: '' },
    methods: {
        onFileChange: function onFileChange(e) {
            var files = e.target.files || e.dataTransfer.files;
            if (!files.length)
                return;
            this.createImage(files[0]);
        },
        createImage: function createImage(file) {
            var image = new Image();
            var reader = new FileReader();
            var vm = this;
            reader.onload = function (e) {
                vm.image = e.target.result;
            };
            reader.readAsDataURL(file);
        }, …
Run Code Online (Sandbox Code Playgroud)

laravel vue.js

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