我正在尝试使particles.js适应以下示例中的Vue.js组件:https ://codepen.io/MichaelVanDenBerg/pen/WpXGRm
但是,当使用下面的代码时,我在控制台中收到以下错误消息:
[Vue 警告]:挂载钩子错误:“TypeError: this.particles is not a function”
如何在下面的代码中修复它?
模板:
</template>
<div>
<div id="particles-js"></div>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
脚本:
<script>
import particles from 'particles.js'
export default {
mounted() {
this.initParticles()
},
methods: {
initParticles () {
particles("particles-js", {
"particles": {
"number": {
"value": 80,
"density": {
"enable": true,
"value_area": 700
}
},
"color": {
"value": "#ffffff"
},
"shape": {
"type": "circle",
"stroke": {
"width": 0,
"color": "#000000"
},
"polygon": {
"nb_sides": 5
},
},
"opacity": {
"value": …Run Code Online (Sandbox Code Playgroud) 如何使用 Laravel Artisan Tinker 编写两行命令?
User::whereEmail('john.doe@home.com')
->get()
Run Code Online (Sandbox Code Playgroud)
PHP 解析错误:语法错误,第 1 行出现意外的 T_OBJECT_OPERATOR
我希望我的UITableViewCells的背景显示每两个单元格有不同的颜色,但当我向下和向后滚动时,它们都会得到相同的颜色.如何知道我的单元格具有不同的contentView大小(根据其内容)?
#define FONT_SIZE 14.0f
#define CELL_CONTENT_WIDTH 320.0f
#define CELL_CONTENT_MARGIN 20.0f
#define NAME_CELL_HEIGHT 20.0f
#import "CartCell.h"
@implementation CartCell
@synthesize nameLabel = _nameLabel;
@synthesize ingredientsLabel = _ingredientsLabel;
@synthesize myStore;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
myStore = [Store sharedStore];
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.nameLabel = nil;
self.ingredientsLabel = nil;
// SET "NAME" CELL
self.nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[self.nameLabel setLineBreakMode:UILineBreakModeWordWrap];
[self.nameLabel setMinimumFontSize:FONT_SIZE];
[self.nameLabel setNumberOfLines:1];
[self.nameLabel setTag:1];
self.nameLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
[self.nameLabel sizeToFit];
self.nameLabel.backgroundColor = [UIColor clearColor];
[[self contentView] …Run Code Online (Sandbox Code Playgroud) 如何将一堆 png 或 webp 图像转换为 webp 动画?
我试过这个:
convert mytiles.png -crop 100x100 +repage tmp.webp
Run Code Online (Sandbox Code Playgroud)
但我只是得到一堆 webp 图像而不是动画。
在以下请求中:
SELECT
myid,
min(name) AS name,
array_agg(array[zip, city])) AS city
FROM my_table
WHERE name LIKE 'Doe'
GROUP BY myid
LIMIT 10
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
+-------+------+-------------------+
| myid | name | city |
+-------+------+-------------------+
| A123 | Doe | {{69,"Groville"}} |
| B456 | Doe | {{NULL,NULL}} |
+-------+------+-------------------+
Run Code Online (Sandbox Code Playgroud)
我怎样才能摆脱这些NULL值并获得一个空字段city?
===编辑===
按照@a_horse_with_no_name 的建议,在查询中替换为(array_agg(name))[1] AS name。min(name) AS name
我在 Ubuntu 上使用以下命令列出包含给定模式的所有文件:
for f in *; do if grep -zoPq "foo\nbar" $f; then echo $f; fi; done
Run Code Online (Sandbox Code Playgroud)
但是在 macos 上,我收到以下错误:
grep: invalid option -- z
Run Code Online (Sandbox Code Playgroud)
-z与 gnu grep 不同,没有选项可以使用 macos grep 将文件视为大字符串。
macos 上是否有另一个选项grep相当于 `-z ?如果没有,我可以使用什么替代方法来获得相同的结果?
我创建了一个中间件来检查新用户电子邮件是否已得到验证middleware/verify_email.js:
export default function (context) {
if (context.$auth.loggedIn && !context.$auth.user.email_verified_at) {
console.log('logged in with email not verified');
return context.redirect('/auth/verify');
}
}
Run Code Online (Sandbox Code Playgroud)
然后,我在全局设置了这个中间件nuxt.config.js:
router: {
middleware: ['auth', 'verify_email']
},
Run Code Online (Sandbox Code Playgroud)
但似乎我遇到了无限循环,页面没有响应。当我评论重定向行时,它会再次响应。
NavigationDuplicated:避免冗余导航到当前位置:“/auth/verify”。
我可能需要为页面的中间件添加一个例外,auth/verify但我不知道如何添加。
知道我应该如何解决这个问题吗?
以下是我尝试过的:
\n\xe2\x9e\x9c ~ brew rm virtualbox\n==> Uninstalling Cask virtualbox\nError: Failure while executing; `brew cask uninstall virtualbox-extension-pack` exited with 127. Here's the output:\nNo such file or directory - brew\n\n\xe2\x9e\x9c ~ brew cask rm virtualbox\n==> Uninstalling Cask virtualbox\nError: Failure while executing; `brew cask uninstall virtualbox-extension-pack` exited with 127. Here's the output:\nNo such file or directory - brew\n\xe2\x9e\x9c ~ \nRun Code Online (Sandbox Code Playgroud)\n 我以恒定的时间间隔从 API 获取 Nuxt 组件中的日志,然后显示它。
setInterval当组件未显示时如何停止该方法(并在再次显示时重新启动它)?
<template>
<v-container>
<v-row>
<v-col class="text-center"> Logs </v-col>
</v-row>
<v-row>
<v-col>{{ logs }}</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
data() {
return {
logs: null,
}
},
mounted() {
setInterval(this.getLogs, 2000)
},
methods: {
async getLogs() {
console.log('getting logs')
await this.$axios
.get('logs/custom')
.then((res) => (this.logs = res.data))
.catch((err) => {
console.log(err)
})
},
},
}
</script>
Run Code Online (Sandbox Code Playgroud) 如何<script>使用字符串名称调用模板中设置的变量?
例如,在下面的示例中,我想使用以下方式调用foo变量table[0]:
<template>\n <div>\n {{ table[0] }}\n {{ table[1] }}\n </div>\n</template>\n\n<script>\nexport default {\n data() {\n return {\n foo: 'Hello World!',\n bar: '\xe5\xa4\xa7\xe5\xae\xb6\xe5\xa5\xbd!',\n table: ['foo', 'bar']\n }\n }\n}\n</script>\nRun Code Online (Sandbox Code Playgroud)\n vue.js ×3
homebrew ×2
nuxt.js ×2
cocoa-touch ×1
grep ×1
imagemagick ×1
ios ×1
laravel ×1
macos ×1
middleware ×1
objective-c ×1
particles.js ×1
postgresql ×1
sql ×1
tinker ×1
uitableview ×1
vuejs2 ×1