我正在开发一个离子应用程序.其中包含我的主页上的文章列表,每篇文章都有一个评论图标,该图标应作为文章页面中评论部分的链接.
如何从该首页链接到文章页面评论部分的锚点?
更新
由于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) 我正在使用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)
但是,这会引发一个警告:
警告:设置假工人
那么导入工人的正确方法是什么,为什么我会收到此警告?
我想知道在laravel中更改最简单的方法是将数据库中的时间戳保存为unix有效时间戳?
提前致谢!
我有表评论、投票、观点、喜欢,其中有article_id 字段。我试图根据这些表中出现的次数获取前 5 篇文章。我正在发送$modelName到我的函数,然后尝试从查询中获取结果。这就是我的查询现在的样子:
private function query($modelName) {\n $mostSomethingArticle = $modelName->all()->groupBy('article_id')->take(5);\n\n return $mostSomethingArticle;\n\n }\nRun Code Online (Sandbox Code Playgroud)\n\n现在,我得到这样的结果:
\n\nCollection {#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}\nRun Code Online (Sandbox Code Playgroud)\n\n我想知道如何进行查询,以获取前 5 个结果以及按顺序出现的次数'desc'。
我正在尝试在我的宅基地上设置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错误消息:
哎呀,看起来像出事了.
在我的 Laravel 应用程序中,我对管理员和用户有不同的身份验证。所以我也有不同的看法。我已将 authviews文件夹放在admin文件夹中,以便我的管理员身份验证的视图路径现在admin.auth.login是例如。我在哪里可以更改这些路径,以便我可以将它们用于所有身份验证功能?
当我尝试保存或更新模型时,对于 spid_id 字段,出现以下错误。我不确定出了什么问题。
一般错误:1366 不正确的整数值:第 1 行的列 'spid_id' 的 ''(SQL:更新
magazines集spid_id= ,updated_at= 2016-10-21 08:28:46,summary= whereid= 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) 我第一次使用React YouTube 包,我正在尝试在 React 组件中嵌入和自定义 YouTube 播放器:
\nconst options = {\n height: \'auto\',\n width: \'100%\',\n playerVars: {\n // https://developers.google.com/youtube/player_parameters\n controls: 0\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n从文档中我可以看到我使用了正确的参数,但是如果我尝试像这样传递它们:
\n<YouTube videoId="xyQ5qD-u-J7" opts={options} ref={videoElement}/>\nRun Code Online (Sandbox Code Playgroud)\n但是,打字稿抛出错误:
\nTS2769: 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) 我已经通过迁移向我的数据库中的表添加了一个新列.该列已正确创建.但是当我试图给它写值时,什么都没有写出来.这是我的代码:
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中写入任何内容.不知道为什么会这样?
我试图在我的视图中第一次使用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 ×4
mysql ×3
php ×3
javascript ×2
reactjs ×2
angularjs ×1
eloquent ×1
homestead ×1
laravel-5 ×1
laravel-5.3 ×1
ngrok ×1
pdf.js ×1
typescript ×1
vue.js ×1